[eluser]Krasser[/eluser]
Im using folder to manage my controllers:
Controller
|_ customer
|_ customers.php
Here is my code: customers.php
Code:
private $row_limit = 2;
Code:
$this->load->model(array('customer/mCustomer')); // Contructor
Code:
public function index()
{
/* Customer/index() : CODE START HERE */
ob_start();
$this->ajax_page(0);
$initial_content = ob_get_contents();
ob_end_clean();
$data['load_first'] = '<link rel="stylesheet" href="'.base_url().'static/theme/css/button.css" type="text/css" media="screen" /> ';
$data['load_last'] = '[removed] function serialize_form() { return $("#customer_table").serialize(); } [removed]';
$data['content'] = 'customer/list';
$data['content_table'] = $initial_content;
$this->load->view('theme',$data);
/* Customer/index() : CODE END HERE */
}
Code:
public function ajax_page($offset = 0)
{
$offset = $this->uri->segment(4,0);
$limit = $this->row_limit;
$config['additional_param'] = 'serialize_form()';
$config['base_url'] = site_url('server/customer/ajax_page/');
$config['div'] = '#content';
$config['total_rows'] = $this->mCustomer->count_customers();
$customers = $this->mCustomer->get_customers($limit, $offset);
$config['per_page'] = $limit;
$this->jquery_pagination->initialize($config);
$content = '';
foreach ($customers as $row)
{
$content .= '<tr><td>';
if ($row->c_deactive == 1)
{
$content .= '<span class="red">Deactive<span>';
} else {
$content .= '<span class="green">Active<span>';
}
$content .= '</td>
<td>
<strong>'. $row->c_name .'</strong><br/>
<cite>'. $row->c_notes .'</cite>
</td><td>'. anchor('customer/update/'.$row->c_account_number,img(base_url().'static/theme/icons/pencil.png')) .'';
if ($row->c_deactive == 1)
{
$content .= anchor('customer/reactive/'.$row->c_account_number,img(array('src' => base_url().'static/theme/icons/flag_green.png', 'alt' => 'Reactive')), array('class' => 'reactive_customer', 'id' => $row->c_account_number));
} else {
$content .= anchor('customer/deactive/'.$row->c_account_number,img(array('src' => base_url().'static/theme/icons/delete.png', 'alt' => 'Deactive')), array('class' => 'deactive_customer', 'id' => $row->c_account_number));
}
$content .= '</td></tr>';
}
$html = '<table border="0" class="tablesorter" cellspacing="0">
<thead>
<tr><th>Status</th>
<th>Customer Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>'. $content .'</tbody>
<tfoot>
<tr>
<td colspan="2">'. $this->jquery_pagination->create_links() .'</td>
</tr>
</tfoot>
</table>';
echo $html;
// $this->load->view('customer/ajax_list',$data);
}
Here is my model: mCustomer.php
Code:
function get_customers($limit = 0, $offset = 0, $search_customer_name = '')
{
$this->db->like($this->customer_name, $search_customer_name);
$this->db->where($this->customer_removed, 0);
$this->db->order_by($this->customer_deactived);
$this->db->order_by($this->customer_id,'DESC');
$this->db->limit($limit, $offset);
$query = $this->db->get($this->customer_table_name);
return $query->result();
}
Im have modified Tohin's Jquery Pagination: Jquery_pagination.php
Code:
var $uri_segment = 4; // Im only change 3 to 4
THE PROBLEM IS I CAN CORRECT VISIT IN FIRST TIME, TABLE AND PAGINATION IS DISPLAY CORRECT. BUT WHEN I CLICK TO SECOND PAGE, TABLE & PAGINATION IS NOT HERE, BLANK DISPLAY!!