jqgrid - In the Paging footer, aren't the Page [1 ] of 0 suppose to say "Page [0 ] of 0" if no record is found? -


i noticed if there's no records returned shouldn't paging footer "0 of 0" instead of "1 of 0"??

also, shouldn't paging textbox disabled well.

this json response sent jqgrid

{ "total":0, "page":0, "records":0, "rows":[] } 

i'm using jqgrid version 4.5.0

thanks...

p.s. source code below...

        $('#'+jqgridspreadsheetid).jqgrid({             url: '../websrvc/jqgrid.ashx',             datatype: 'json',             mtype: 'post',             postdata: { whichjqgridtemplate: '<%=jqqridtools.template.myinventory%>', whichaction: '<%=jqqridtools.action.display%>', webpagequickquotesaleprice: '<%=postquickquotesaleprice%>' },             colnames: ['id', 'stock number', 'vin', 'year', 'make', 'model', 'trim', 'mileage', 'purchase price', 'stock date', 'repair cost', 'total cost', 'days in inventory', 'hidden-inventory-tracker-location-id', 'inventory tracker location', 'links'],  //display text in column header...             colmodel: [                        //in case, use "sorttype" property in "colmodel" work when "loadonce" set true...                        //formatter doc --> "http://www.trirand.com/jqgridwiki/doku.php?id=wiki:predefined_formatter&s[]=cell&s[]=formatter"...                        //formatter hyperlink --> stackoverflow posting said use formatter's function declaration instead of formatter's "showlink" followed "formatoptions"...                        //                    --> (old link) - http://stackoverflow.com/questions/5010761/linking-from-a-column-value-in-jqgrid-to-a-new-page-using-get...                        //                    --> (new link) - http://stackoverflow.com/questions/14529358/jqgrid-need-hyperlink-need-to-capture-value-through-jquery/14537512#14537512...                        //                    --> (new link) - http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter...                        //                    --> reasons --> 1) far simpiler use formatter reading/writing , 2) quicker , better performance...                        { name: 'id', index: 'id', sorttype: 'int', width: 0, align: 'left', hidden: true, hidedlg: true },  //"hidedlg" use hide hidden column in "column chooser"...                        { name: 'stocknumber', index: 'stocknumber', sorttype: 'text', width: 100, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },                        { name: 'vin', index: 'vin', sorttype: 'text', width: 140, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },                        { name: 'year', index: 'year', sorttype: 'int', width: 50, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },                        { name: 'make', index: 'make', sorttype: 'text', width: 80, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },                        { name: 'model', index: 'model', sorttype: 'text', width: 80, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },                        { name: 'trim', index: 'trim', sorttype: 'text', width: 100, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },                        { name: 'mileage', index: 'mileage', sorttype: 'int', width: 60, align: 'center', formatter: 'number', formatoptions: {decimalseparator:'',thousandsseparator:',',decimalplaces:0,defaultvalue:'0'} },                        { name: 'purchaseprice', index: 'purchaseprice', sorttype: 'currency', width: 80, align: 'center', formatter: 'currency', formatoptions: {decimalseparator:'.',thousandsseparator:',',decimalplaces:2,defaultvalue:'0.00',prefix:'$',suffix:''} },                        { name: 'stockdate', index: 'stockdate', sorttype: 'date', width: 90, align: 'center', formatter: 'date', formatoptions: { newformat: 'm/d/y' } },  //"formatter" , "formatoptions" required date sorting works properly...                        { name: 'repaircost', index: 'repaircost', sorttype: 'currency', width: 80, align: 'center', formatter: 'currency', formatoptions: { decimalseparator: '.', thousandsseparator: ',', decimalplaces: 2, defaultvalue: '0.00', prefix: '$', suffix: '' } },                        { name: 'totalcost', index: 'totalcost', sorttype: 'currency', width: 80, align: 'center', formatter: 'currency', formatoptions: { decimalseparator: '.', thousandsseparator: ',', decimalplaces: 2, defaultvalue: '0.00', prefix: '$', suffix: '' } },                        { name: 'daysininventory', index: 'daysininventory', sorttype: 'int', width: 65, align: 'center', formatter: 'number', formatoptions: { decimalseparator: '', thousandsseparator: ',', decimalplaces: 0, defaultvalue: '1' } },                        { name: 'inventorytrackerlocationid', index: 'inventorytrackerlocationid', sorttype: 'int', width: 0, align: 'left', hidden: true, hidedlg: true },  //"hidedlg" use hide hidden column in "column chooser"...                        { name: 'inventorytrackerlocation', index: 'inventorytrackerlocation', sorttype: 'text', width: 120, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },                        //links not present in json data website, customize here...                        { name: 'links', index: 'links', sorttype: 'text', width: 80, align: 'center', formatter: function (cellvalue, options, rowobject) { return "<span style='text-decoration:underline;cursor:pointer;'>links</span>" }, search: false }  //"search" use hide field in search dialog...             ],             beforeselectrow: function (rowid, e) {                 //http://stackoverflow.com/questions/16592547/how-to-have-custom-formatter-built-in-function-to-call-a-non-jqgrid-seperate-fun                 //http://stackoverflow.com/questions/16592547/how-to-have-custom-formatter-built-in-function-to-call-a-non-jqgrid-seperate-fun                 //http://stackoverflow.com/questions/14529358/jqgrid-need-hyperlink-need-to-capture-value-through-jquery/14537512#14537512                 //http://stackoverflow.com/questions/13761222/how-to-fire-loadcomplete-after-new-row-is-added-in-jqgrid/13765086#13765086                 //to attached javascript function clickable "links" cell...                 if (this.p.colmodel[$.jgrid.getcellindex($(e.target).closest("td")[0])].name === jqgridcolumnnamelinks) {                     jqgridpopupdialoglinkoptions(                         $(this).getcell(rowid, jqgridcolumnidstocknumber),                //use $(this) instead less overhead - it's oleg @ jqgrid said....                         $(this).getcell(rowid, jqgridcolumnidvin),                        //use $(this) instead less overhead - it's oleg @ jqgrid said....                         $(this).getcell(rowid, jqgridcolumnidinventorytrackerlocationid)  //use $(this) instead less overhead - it's oleg @ jqgrid said....                     );                     return false;                 }             },             pager: '#'+jqgridpagerid,             rownum: 10,             rowlist: [5, 10, 20, 50],  //drop-down selection in footer - show how many rows per page...             //this "sortname"/"sortorder" tag must specified "getgridparam"'s 'datatype'/'sortname'/'sortorder' (column sorting) work.  (some kind of jqgrid bug or feature need hack workaround with)...             <%if(postquickquotesaleprice.length > 0) {%>             sortname: 'totalcost', sortorder: 'desc',  //when coming quick-quote webpage...             <%} else {%>             sortname: 'stockdate', sortorder: 'desc',  //when coming webpages, product webpage...             <%}%>             viewrecords: true,             //gridview: true,             //imgpath: '',             caption: 'my inventory',             width: 1022,             shrinktofit: false,             height: 400,             sortable: true,  /* allows both 1) moving columns sideway other location fields , 2) jqgrid column chooser plugin / jquery multiselect plugin work... */             grouping: true,  /* allows row data group row grouping... */             loadonce: true,  //in case, use "sorttype" property in "colmodel" work when "loadonce" set true...             emptyrecords: "no records display",             loaderror: function (xhr, st, err) {                 alert("an error had occurred, please try again or notify webmaster of error");             },             loadcomplete: function () {                 //http://stackoverflow.com/questions/16639339/how-do-i-get-a-column-to-be-sort-in-descending-order-upon-loading...                                    //=========================================================================================                 // code executed @ first loading because jqgrid                 // changes datatype "local" after first loading if use                 // loadonce option. use settimeout allows jqgrid make first                 // loading till end , reload after                 //=========================================================================================                 var $self = $(this);  //this needed seperate objects seperate binding jqgrid or $(this) objects work.  wouldn't work if binded itself...                 if ($self.jqgrid('getgridparam', 'datatype') === 'json') {  //this value when loading webpage value of "datatype" option become "local" afterward...                     //$self.getgridparam({ sortname: 'totalcost', sortorder: 'desc' });  //when coming quick-quote webpage...                     //$self.getgridparam({ sortname: 'stockdate', sortorder: 'desc' });  //when coming webpages, product webpage...                     //$(this).triggerhandler('reloadgrid', [{ sortname: 'year', sortorder: 'desc' }]);                     settimeout(function () {                         //$('#' + jqgridspreadsheetid).triggerhandler('reloadgrid', [{ sortname: 'year', sortorder: 'desc' }]);                         $self.triggerhandler("reloadgrid");                     }, 50);                 }                 //=========================================================================================                 jqgridsummaryspreadsheetdisplay();             }         }); 

here's snapshot using firefox firebug. can see json result asked me do, use "page":"0" instead of "page":0 . jqgrid in webpage showed 1 instead of 0.

enter image description here

i think problem in the line of jqgrid source code

ts.p.page = $.jgrid.getaccessor(data,dreader.page) || ts.p.page || 0; 

you should change integer value of page string value:

{ "total":0, "page":"0", "records":0, "rows":[] } 

or

{ "total":"0", "page":"0", "records":"0", "rows":[] } 

which exact corresponds format described in the documentation.

updated: the demo reproduce problem , another demo uses fixed json data ("page":"0" instead of "page":0). how can see fix work.

updated 2: see problem in usage of loadonce: true. fix problem 1 can use

localreader: {     page: function (obj) {         return obj.page !== undefined ? obj.page : "0";     } } 

see one more demo.

updated 3: posted the full request fix problems. fix merged (see here) main code of jqgrid on github.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -