Skip to content Skip to sidebar Skip to footer

JqGrid: Reload Data From Json-string

I know, that there is several similar questions are exists on SO, but despite it I creating this question because: - I still don't get it :) - I want to create a topic that possib

Solution 1:

It's very seldom that you really need to use datatype which values other as "local", "json", "jsonp" or "xml". Most usage of other datatype can be easy replace to the tree main datatypes. If you use "jsonstring", "xmlstring" or "clientSide" then the datatype will be changed to "local" after loading of data (see the line of source code for example). So if you really need to use datatype: "jsonstring" you can fix reloading by usage

$("#grid").setGridParam({
    datastr: myNewData,
    datatype: "jsonstring" // !!! reset datatype
}).trigger("reloadGrid");

Additionally I could see that you used pager: false option of jqGrid. It's wrong option. If you don't need to use local paging of data I recommend you

  1. don't include and pager option. Default value pager: "" is already OK.
  2. include rowNum parameter with some large enough value like rowNum: 10000. Default value of rowNum is 20. So if you don't want to display only the first 20 rows of the input data you should increase the value of rowNum.

The last recommendation: you should include sorttype: "integer" (see the documentation) to columns which holds integer values. It will fix sorting of data if the user clicks on the column header. You should consider to use column templates too (see the old answer).


Post a Comment for "JqGrid: Reload Data From Json-string"