Retrieving contents of the grid
I am using jqGrid to display values on the client side. Initially the grid is empty and the user enters the data inline. According to the requirement, I need to submit the data once the user submits the form.
I intend to, just prior to submitting the form, format contents so that I can store the user entered details in the database. Is their any way I can get a grid data in the form of JSON?
Currently I am doing the same in the following way:
var ids = $(gridId).jqGrid('getDataIDs');
for ( var i =1; i <=ids.length; i++) {
var id = ids[i];
rowData = $("#"+grid).jqGrid('getRowData',id);
}
//add rowData to some global object and inturn to some hidden field and se开发者_Python百科nding it the server.
Is there any other way to do the same?
I would recommend you to use
var gridData=$("#list").jqGrid('getGridParam','data');
to get full data from the grid. After you have all the data in one JavaScript object gridData
you can modify it in the way which you need prior to submitting to the server.
精彩评论