Rebooting jQGrid does not work when table becomes empty

I have a problem with jqGrid relaod.

So here is what I have.

when my page load i build a table

$("#systemPropList").jqGrid( { url : '${servletPath}/systemProperties.data', colNames:['Key Name','Key Value','Description','System Name','Work'], colModel : [ {name:'propertyKey',index:'propertyKey', width:155, align:'center'}, {name:'propertyValue',index:'propertyValue', width:100, align:'center'}, {name:'propertyDescription',index:'propertyDescription'}, {name:'propertySystemName',index:'propertySystemName', width:100, align:'center'}, {name:'propertyId', sortable:false, width:60, align:'center', formatter:workButtons } ], sortname: 'propertyKey', sortorder: "desc" }) 

I have a selection box at the top to reload this table based on the value selected from dropbox, and I linked the reload to onChange.

  $("select[name=systemName]").change(function(obj){ gridReload(); }); function gridReload(){ $("#systemPropList").setGridParam({"page": 1}); $("#systemPropList").jqGrid("setGridParam",{postData:{propertySystemName : $("#systemName option:selected").val()}}).trigger("reloadGrid"); } 

This works fine until I select an option for which data is available. But as soon as I select a parameter that does not have any data, the table will become empty even after the table remains empty, even if I change the selection.

I checked through firebug that there is no JS error, and the reboot makes the correct call to the server, and the server returns the data.

What am I missing?

+4
source share
1 answer

First of all, I think it's better to use postData with propertySystemName defined as a function:

 postData: { propertySystemName: function () { return $("#systemName option:selected").val(); } } 

(for more details see the answer). After that, you will not need to reset the propertySystemName inside change (or inside gridReload ).

What you can do is the following

 function gridReload() { $("#systemPropList").jqGrid("setGridParam", {lastpage: 1}) .trigger("reloadGrid", [page: 1]); } 
+2
source

Source: https://habr.com/ru/post/1483854/


All Articles