I'm very confuse for this problem due I'm new in jqGrid.
my data just show 10 rows. this my script;
jQuery("#list").jqGrid({
url:'dounfinish.php?q=1',
datatype: 'json',
mtype: 'POST',
closeafteredit:true,
colNames:['id','Date', 'Line','Model','Lotno','Qty','PIC'],
colModel :[
{name:'id', index:'id', hidden:true, width:55},
{name:'Date', index:'Date', width:90, editable:true, search:true, stype:'text',searchoption:{sopt:['cn']}},
{name:'Line', index:'Line', width:80, editable:true, search:true, stype:'text',searchoptions:{sopt:['cn']}},
{name:'Model', index:'Model', width:180, editable:true, search:true, stype:'text',searchoption:{sopt:['cn']}},
{name:'Lotno', index:'Lotno', width:80, editable:true, search:true, stype:'text',searchoption:{sopt:['cn']}},
{name:'Qty', index:'Qty', width:80, editable:true, search:true, stype:'text',searchoptions:{sopt:['cn']}},
{name:'PIC', index:'PIC', width:180, editable:true, search:true, stype:'text',searchoption:{sopt:['cn']}}
],
// pager: jQuery('#pager'),
gridview:true,
pager: '#pager',
width: '100%',
height: '100%',
rowNum:10,
rowList:[10,20,30],
sortname: 'Date',
sortorder: "desc",
viewrecords: true,
loadonce: true,
// imgpath: 'themes/basic/images',
caption: 'DAILY CHECK QTY',
editurl:'process3.php',
prmNames:{oper:'action',editoper:'editbaldefect',id:'def_id'}
});
the case like:
loadonce: true result View 1 - 10 of 10 --> column filter can work.
loadonce: false result View 1 - 10 of 3500 --> column filter not working.
Why??
at developer tools show:
{"page":1,"total":33223,"records":"332222","rows":[]}
but at php page appears:
UPDATE
my jqgrid using datetype : json
and also need loadonce : true
.I already trial like this:
- change loadonce : false –> result all records show but can't use toolbar filter
- change loadonce : true –> result only show 10 records but toolbar filter can work
- loadonce : true, rowNum: 50 –> data show only 50 (next button disable)
- check query at phpmyadmin –> result all data can show (query OK)
- using another table (OK one) –> result still not work
- Using another page then attach jqgrid –> still not work
why jqgrid just retrieve 10 records only however this table actually have 100.000 records?
and why just this table whereas another table can work.
Best Answer
jqGrid was designed originally to be able to fill grid with server based data. The option
loadonce: true
was introduced later. So if you don't useloadonce
(or if you useloadonce: false
) the server is responsible for paging, sorting and filtering of the data. Every time if the user click on the column header to sort the data by the column or if the user fill searching toolbar the new request to the server will be sent. If the user change the number of rows per page (choose other value as 10 in the pager) the new request to the server will be also send. The optionspage
,rows
,sidx
,sord
,_search
and typicallyfilters
. Default names of parameters which will be sent to the server can be chaneged byprmNames
option of jqGrid (see the documentation).I personally use always
stringResult: true
option offilterToolbar
. The format offilters
parameter in the case is the same as for Advanced Searching (see here).If you use
loadonce: true
then jqGrid get the data from the server only once. So the server should return all data in the response independent on therows
parameter of jqGrid. The server should only sort the data correctly. The propertiespage
,total
andrecords
from the server response will be ignored. The corresponding values will be recalculated based on the data fromrows
.If you use
loadonce: true
then jqGrid changedatatype
to"local"
after the first loading of data. So all later requests for sorting, paging and filtering of data will be implemented locally without any additional request to the server.So if you use
loadonce: true
and the server return 10 rows of data then jqGrid display"View 1 - 10 of 10"
because it found only 10 rows in the server response.