I am trying to get pagination and list.js (sort and search) to work with my table.
I have tried any advice I can find online, the pagination works correctly, and list.js works correctly search and sort works. But only on the items on that page. I.E I have 13 records and 5 per page, so 3 pages. List.js only searches and sorts the records on that page. Not on the pages that arent displayed.
The code in my tickets controller is as follows
$data['main_view'] = "tickets/index";
//loading pagination library
$this->load->library('pagination');
$query = $this->db->get('tickets','5',$this->uri->segment(3));
$data['tickets'] = $query->result();
//get all tickets
$query2 = $this->db->get('tickets');
$config['base_url'] = 'http://localhost/helpdesk/tickets/index/';
$config['total_rows'] = $query2->num_rows();
$config['per_page'] = 5;
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_tag_open'] = '<li>';
$config['last_tag_open'] = '<li>';
$config['next_tag_open'] = '<li>';
$config['prev_tag_open'] = '<li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['first_tag_close'] = '</li>';
$config['last_tag_close'] = '</li>';
$config['next_tag_close'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class=\"active\"><span><b>";
$config['cur_tag_close'] = "</b></span></li>";
$this->pagination->initialize($config);
$this->load->view('layouts/main',$data);
The code for my table view is as follows
<div id="tickets">
<input class="search" placeholder="Search" />
<table class="table table-hover">
<thead>
<tr class=table-danger>
<th class="sort" data-sort="Title">
Title
</th>
<th class="sort" data-sort="Creator">
Creator
</th>
<th class="sort" data-sort="Date">
Date
</th>
<th class="sort" data-sort="SLA">
Service Level Agreement
</th>
<th class="sort" data-sort="Status">
Status
</th>
</tr>
</thead>
<tbody class="list">
<?php
foreach($tickets as $ticket):?>
<?php if($ticket->sla == 1){ ?>
<tr style='background-color: #e6dfcb;'>
<?php echo "<td class = 'Title'><a href = '". base_url() ."tickets/display/".$ticket->ticket_id ." '>". $ticket->ticket_title. "</a></td>"; ?>
<?php echo "<td class = 'Creator'>". $ticket->ticket_creator. "</td>"; ?>
<?php echo "<td class = 'Date'>". $ticket->ticket_date_reported. "</td>"; ?>
<?php echo "<td class = 'SLA'>". 'Elevated'. "</td>"; ?>
<?php if($ticket->Status == 0){
echo "<td class = 'Status'>". 'Open'. "</td>"; }
elseif($ticket->Status == 1){
echo "<td class = 'Status'>". 'Hold'. "</td>"; }
elseif($ticket->Status == 2){
echo "<td class = 'Status'>". 'Awaiting End User'. "</td>"; }
elseif($ticket->Status == 3){
echo "<td class = 'Status'>". 'Resolved'. "</td>"; }
elseif($ticket->Status == 4){
echo "<td class = 'Status'>". 'Closed'. "</td>"; }
else{
echo "<td class = 'Status'>". 'Unknown'. "</td>"; }?>
<td><a class = "btn btn-warning" href="<?php echo base_url();?>tickets/edit/<?php echo$ticket->ticket_id?>"><span class="glyphicon glyphicon-edit"></span></a></td>
<td><a class = "btn btn-danger" href="<?php echo base_url();?>tickets/delete/<?php echo$ticket->ticket_id?>"><span class="glyphicon glyphicon-remove"></span></a></td>
</tr>
<?php }
elseif($ticket->sla ==2){?>
<tr style='background-color: #e6cbe6;'>
<?php echo "<td class = 'Title'><a href = '". base_url() ."tickets/display/".$ticket->ticket_id ." '>". $ticket->ticket_title. "</a></td>"; ?>
<?php echo "<td class = 'Creator'>". $ticket->ticket_creator. "</td>"; ?>
<?php echo "<td class = 'Date'>". $ticket->ticket_date_reported. "</td>"; ?>
<?php echo "<td class = 'SLA'>". 'Contract'. "</td>"; ?>
<?php if($ticket->Status == 0){
echo "<td class = 'Status'>". 'Open'. "</td>"; }
elseif($ticket->Status == 1){
echo "<td class = 'Status'>". 'Hold'. "</td>"; }
elseif($ticket->Status == 2){
echo "<td class = 'Status'>". 'Awaiting End User'. "</td>"; }
elseif($ticket->Status == 3){
echo "<td class = 'Status'>". 'Resolved'. "</td>"; }
elseif($ticket->Status == 4){
echo "<td class = 'Status'>". 'Closed'. "</td>"; }
else{
echo "<td class = 'Status'>". 'Unknown'. "</td>"; }?>
<td><a class = "btn btn-warning" href="<?php echo base_url();?>tickets/edit/<?php echo$ticket->ticket_id?>"><span class="glyphicon glyphicon-edit"></span></a></td>
<td><a class = "btn btn-danger" href="<?php echo base_url();?>tickets/delete/<?php echo$ticket->ticket_id?>"><span class="glyphicon glyphicon-remove"></span></a></td>
</tr>
<?php }
else{?>
<tr>
<?php echo "<td class = 'Title'><a href = '". base_url() ."tickets/display/".$ticket->ticket_id ." '>". $ticket->ticket_title. "</a></td>"; ?>
<?php echo "<td class = 'Creator'>". $ticket->ticket_creator. "</td>"; ?>
<?php echo "<td class = 'Date'>". $ticket->ticket_date_reported. "</td>"; ?>
<?php echo "<td class = 'SLA'>". 'Basic'. "</td>"; ?>
<?php if($ticket->Status == 0){
echo "<td class = 'Status'>". 'Open'. "</td>"; }
elseif($ticket->Status == 1){
echo "<td class = 'Status'>". 'Hold'. "</td>"; }
elseif($ticket->Status == 2){
echo "<td class = 'Status'>". 'Awaiting End User'. "</td>"; }
elseif($ticket->Status == 3){
echo "<td class = 'Status'>". 'Resolved'. "</td>"; }
elseif($ticket->Status == 4){
echo "<td class = 'Status'>". 'Closed'. "</td>"; }
else{
echo "<td class = 'Status'>". 'Unknown'. "</td>"; }?>
<td><a class = "btn btn-warning" href="<?php echo base_url();?>tickets/edit/<?php echo$ticket->ticket_id?>"><span class="glyphicon glyphicon-edit"></span></a></td>
<td><a class = "btn btn-danger" href="<?php echo base_url();?>tickets/delete/<?php echo$ticket->ticket_id?>"><span class="glyphicon glyphicon-remove"></span></a></td>
</tr>
<?php
}
endforeach; ?>
</tbody>
</table>
<ul class ="pagination"></ul>
<?php echo $this->pagination->create_links(); ?>
</div>
My JS in the footer is as follows
<script type = "text/javascript" src="<?php echo base_url();?>assets/js/list.min.js"></script>
<script type = "text/javascript">
var options = {
valueNames: ['Title', 'Creator', 'SLA', 'Date','Status']
page: 3,
pagination: true
};
var tickets = new List('tickets', options);
</script>
Any help would be awesome!