I am sending a string down from a websockets server to my client that has a jqgrid on it.
the string is a JSON object which I”m converting using eval() (I know that’s not best practice, but this is just for a proof of concept at this point).
I’m just trying to reload the jqgrid with:
var obj = eval("(" + msg.data + ")");
$("#list").setGridParam({ "postData" : obj }).trigger("reloadGrid");
where msg is the parameter in my socket.onmessage callback, if I alert (msg.data), I see my correctly formed JSON string, but my grid isn’t reloading.
if I alert obj, I see that it’s converting to an object correctly.
I also tried splitting out the trigger(“reloadGrid”) onto a separate line with my $(“#list) prepending it…still not reloading.
any suggestions?
If you use
datatype: 'jsonstring'anddatastr: msg.dataand you want reload the grid with another data you should understand thatdatatype: 'jsonstring'will be changed todatatype: 'jsonstring'after the first load. ThepostDataparameter will be used only if you communicate with the server. In the case thedatatypemust be either'json'or'xml'. Theurlparameter should be set in the case too.So I you can try to do the following: