Welcome Guest, Not a member yet? Register   Sign In
Jqgrid pagination question?
#1

[eluser]cestaz18[/eluser]
Please help me...
i have a problem in pagination in jqgrid..

the calculation of total rows of all page...
my problem is the total rows count only per page????

Example:
i have 13 rows of data

my rowlist is [10,20,30]

when i choose in dropdown list of rows 10

in page one i have 10 rows the total rows show in the right hand shows like this
view 1-10 of 10

and when i next it to page 2

it shows....

view 11-13 of 3

it seems like it count the number of rows per page...

i want it to show the total numbers of rows or items in all pages..

example:

in the given data i show to you..

i like it to be shown..

in page 1
view 1-10 of 13

and in page 2 view 11-13 of 13

here's my code..

please help me..thanks

-cess-^^



Code:
$page = $this->input->post('page');
        $limit = $this->input->post('rows'); // get how many rows we want to have into the grid
        $sidx = $this->input->post('sidx'); // get index row - i.e. user click to sort
        $sord = $this->input->post('sord'); // get the direction
        
        $query = $this->input->post('query');
        $qtype = $this->input->post('qtype');
        
        if (!$sidx) $sidx = 1;
        if (!$sord) $sord = 'asc';
                
        if (!$page) $page = 1;
        if (!$limit) $limit = 25;
    
        $this->db->start_cache();
        
        if ($qtype == 'role_code' && $query) $this->db->like('role_code', $query);
        if ($qtype == 'role_code' && $query) $this->db->like('role_desc', $query);
        
        // calculate the number of rows for the query. We need this for paging the result
        $this->db->from('sec_role');
        $this->db->where('sec_role.is_deleted','0');
        $num = $this->db->count_all_results();
    
        // calculate the total pages for the query
        if( $num > 0 && $limit > 0) {
              $num = ceil($num/$limit);
        } else {
              $num = 0;
        }
        
        // if for some reasons the requested page is greater than the total
        // set the requested page to total page
        if ($page > $num) $page=$num;
        
        // calculate the starting position of the rows
        $start = $limit * $page - $limit; // do not put $limit*($page - 1)
        
        // if for some reasons start position is negative set it to 0
        // typical case is that the user type 0 for the requested page
        if($start <0) $start = 0;
        
        $this->db->select("role_id as pkey,role_id, role_code, role_desc");
        $this->db->order_by($sidx,$sord);
        $this->db->limit($limit, $start);
        $query = $this->db->get("sec_role");
        
        $this->db->flush_cache();
        
        $data['db'] = $query;
        $data['page'] = $page;
        $data['num'] = $num;
        return $data;


Messages In This Thread
Jqgrid pagination question? - by El Forum - 01-06-2010, 09:33 PM
Jqgrid pagination question? - by El Forum - 01-07-2010, 01:13 AM
Jqgrid pagination question? - by El Forum - 01-14-2010, 12:24 AM
Jqgrid pagination question? - by El Forum - 01-18-2010, 08:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB