开发者

Loading jqGrid via Json MVC Controller

I have the same issue as about 500,000 other users of jqGrid. IE, no rows when I use the url property, which points to an ASP.Net MVC 3 Controller method (which returns JsonView). For some reason, one either needs to provide a JsonReader or use the cell format. My question is why can I load my records using ajax via the same controller method, then set the data property to this collection, and it works fine. I don't need JsonReader or the silly cell formatting Why in the world IS that??

I read somewhere that speci开发者_Python百科fying repeatitems:false would get around the issues of JsonReader and the cell formatting. Is this true???

What I want to do is call ajax, populate grid, let user search in form fields, resubmit ajax, empty grid, set data with new ajax values. How in the world do u empty the grid?

This is sooooooooooooo frustrating.

Heeeeeeeeeeeeeeeeeeeelp


I figured out how to remove (clear) the elements of the jgGrid. Namely, I am using the following:

$("#list2").jqGrid('clearGridData'); //Clear all rows
$('#list2').setGridParam({ data: searchresults }); // Set to the new json result set
$("#list2").trigger("reloadGrid") // reload

This works killer, plus you don't have to deal with the black magic of the JsonReader... whatever is going on behind the scenes is a mystery. The above assumes that searchResults was populated by a return Json(list) from the MVC Controller. So, when a user searches by firstname, lastname, etc, simply do an ajax call to the controller, then reload the grid.

Granted this may not be the most robust solution, but for small result sets it rocks, plus you can trace every step.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜