[eluser]InsiteFX[/eluser]
Download my jQuery pagination here:
Fx_pagination.zip
Controller:
Code:
public function index($offset = '')
{
$this->load->library('fx_pagination');
$this->load->model('demo_model', 'demo');
$data = array();
$limit = 10;
$count = $this->demo->count_all();
/**
* ----------------------------------------------------------------------
* The base_url and segment below must be set to the right URL
* and the segment must be set to the right segment or it WILL NOT WORK!
* ----------------------------------------------------------------------
*/
$config['base_url'] = base_url('home/index/');
$config['uri_segment'] = 3;
$config['full_tag_open'] = '<div id"content" class="text-center"><ul class="pagination pagination-sm page-manage">';
$config['display_pages'] = TRUE;
$config['per_page'] = $limit;
$config['total_rows'] = $count;
$config['num_links'] = 4;
// Turns ON/OFF the Total page display in the DataGrid pagination links.
$config['show_count'] = TRUE;
// Get the database records with limit and offset.
$query = $this->demo->get_with_limit($limit, $offset, 'id asc');
$data["data_grid"] = $query->result();
// Initialize the pagination configuration
$this->fx_pagination->initialize($config);
// Display the pagination links.
$data['pager_links'] = $this->fx_pagination->create_links();
// Rest of your code
}
View: .application/views/manage_view.php
Code:
<div class="panel panel-default manage">
<div class="panel-heading"> Manage Users</div>
<div class="panel-body manage">
<div class="table-responsive">
<table class="table table-bordered table-hover table-condensed manage">
<thead class="active-header">
<tr>
<th class="th-align">#id</th>
<th class="th-align">Download Date</th>
<th class="th-align">Download Type</th>
<th class="text-center">Actions</th>
</tr>
</thead>
<tbody>
<!-- Generate the Twitter Bootstrap Table DataGrid -->
<?php foreach ($data_grid as $item): ?>
<tr>
<td><?php echo $item->id; ?></td>
<td><?php echo $item->download_date; ?></td>
<td><?php echo $item->download_type; ?></td>
<!-- Build actions links -->
<td class="text-center col-lg-2">
<a href="<?php echo base_url('pages/edit/'.$item->id.'/'); ?>" class="btn btn-primary btn-info btn-xs">
<span class="glyphicon glyphicon-edit"></span> Edit
</a>
<a href="<?php echo base_url('pages/delete/'.$item->id.'/'); ?>" class="btn btn-primary btn-danger btn-xs">
<span class="glyphicon glyphicon-remove-circle"></span> Delete
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div> <!-- table-responsive -->
</div> <!-- panel body -->
<div class="panel-footer manage">
<?php echo $pager_links; ?>
</div>
</div> <!-- panel -->