Welcome Guest, Not a member yet? Register   Sign In
JQuery Pagination support uri segment 4??
#1

[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!!
#2

[eluser]InsiteFX[/eluser]
No need to change it in the class just pass it in the config.
Code:
$config['uri_segment'] = 4;
#3

[eluser]Krasser[/eluser]
Im change back to 4 already. Thank.

Here is more detials (Refer to attach):
a. First time visit
b. When Click to Page 2
c FireBug Catch
#4

[eluser]Krasser[/eluser]
C. HERE

FireBug Catch
#5

[eluser]aquary[/eluser]
Check what was the URL called on the second time. I"m wondering about this:
Code:
$config['base_url']             = site_url('server/customer/ajax_page/');


Isn't your controller customers inside customer folder? should the url be customer/customers/ajax_page instead?
#6

[eluser]Krasser[/eluser]
Thank you for reply and helping! I'm FOUND it!
Code:
I have enable GZip page output! Now I'm Disable it work again! WHY???
#7

[eluser]msAdele[/eluser]
Thank you for the information, everyone!
#8

[eluser]InsiteFX[/eluser]
Make sure you also change the Constructor from CI_Pagination to __construct !
#9

[eluser]Krasser[/eluser]
[quote author="InsiteFX" date="1329799871"]Make sure you also change the Constructor from CI_Pagination to __construct ![/quote]

inside JQuery_Pagination Model?
#10

[eluser]InsiteFX[/eluser]
Inside the jQuery_Pagination Class Library!




Theme © iAndrew 2016 - Forum software by © MyBB