Get all rows data of a JQGrid in codebehind?

北城以北 提交于 2019-12-21 05:38:09

问题


I'm adding some rows data to my JQGrid on client side with javascript :

var grid = jQuery("#<%= JQGridMembers.ClientID %>");
var rowKey = grid.getGridParam("selrow");
var newRow = [{ ID: memberId, FullName: memberFullName, Percent: parseInt(percent)}];
grid.addRowData(memberId, newRow);

above code works well , but How can I get all inserted rows data (in JQGrid) in code-behind?


回答1:


You can get all rows from the grid by

var myData = grid.jqGrid('getRowData');

or with respect of

var myData = grid.jqGrid('getGridParam', 'data');

The last way can be used only with local datatype or in case of loadonce: true. It returns data not only from the current page, but all data from all pages.

The getRowData method use unformatter to read the data from all cells of the grid.




回答2:


Had encountered a similar problem, below is what I ended up using

var data = $("#table-id").jqGrid('getGridParam', 'data');
for (var i = 0; i < data.length; i++) {
    var f_name = data[i].FirstName;
    var l_name = data[i].LastName;
    // blah... blah..
}

Reference



来源:https://stackoverflow.com/questions/9749104/get-all-rows-data-of-a-jqgrid-in-codebehind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!