Question

Is this normal or I'm missing something?

If I set loadonce: true, my grid is returning only 5 records.

But if I change it to loadonce: false, the grid is getting all the records

My code is below.

$("#leave-detail-grid").jqGrid({
    url:'grid/grid_leave_detail.php',
    datatype: 'xml',
    mtype: 'GET',
    colNames:['Date','Day','Approver','Leave Type','Status','Purpose | Reason'],
    colModel :[
      {name:'start_date', index:'start_date', width:80, editable:false, align:"left", editrules:{required:true}},
      {name:'day', index:'day', width:80, editable:false, align:"left", editrules:{required:true}},
      {name:'sup', index:'sup', width:130, editable:false, align:"left", editrules:{required:true}},
      {name:'desc', index:'desc', width:130, editable:false, align:"left", editrules:{required:true}},
      {name:'status', index:'status', width:80, editable:false, align:"center", editrules:{required:true}},
      {name:'purpose', index:'purpose', width:180, editable:false, align:"left", editrules:{required:true}}    
    ],
    height: 'auto',
    pager: '#leave-detail-pager',
    pgbuttons: true,
    pginput: 'Yes',
    pgtext: 'Yes',
    rowNum:5,
    rowList:[20,40,100,200,400],
    sortname: 'start_date',
    sortorder: 'asc',
    loadonce: true, // to enable sorting on client side
    viewrecords: true,
    gridview: true,
    caption: 'Search Purpose'
});
$("#leave-detail-grid").jqGrid('navGrid',"#leave-detail-pager",
      {edit:false,add:false,del:false,search:true},
      {zIndex:5234},{zIndex:5234},{zIndex:5234},{zIndex:5234}
);
Was it helpful?

Solution

Thanks Jonathan. How did I miss that demo :)

I add the colModel rowTotal: 2000, value -1 is not working, this will show 2000 recs

then add the below to my server code

$totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false;
if($totalrows) {
$limit = $totalrows;
}

And to load all the records we need to tweak the server code to override the rowTotal parameter.

$result = mysql_query("SELECT COUNT(*) AS count FROM leaveform WHERE emp_id='$emp_id'   AND company_id='$company_id'"); 
$row = mysql_fetch_array($result,MYSQL_ASSOC); 
$count = $row['count']; 
$totalrows =  $count;
$limit = $totalrows;

OTHER TIPS

rowNum:5, means that the grid will only use 5 rows.

loadonce: true means that it will only load once. It also disables the pager.

Based on this configuration, that grid will only use 5 rows, and since it will not load anymore from the server, it will always be the same 5.

Here a link to the Wiki which has the latest options documentation: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options

If you use loadonce: true the server should return all rows. the data should be sorted coresponds to sortname and sortorder parameters which will be send to the server as sidx and sord.

The first page of the returned data will be displayed. You will be still able to use local paging, sorting and filtering (searching) of the data.

It could be important to define sorttype parameter to allow correct local sorting of the data.

If you still have the problem you should append your question with the XML response from the server. So other reader of your question would be able to reproduce the problem.

The last remark: you use very strange values for pginput, and pgtext options of jqGrid. You should better to hold the types of options described in the documentation.

{ rowNum: 0 } to set no limit rows...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top