jqGrid batch save - how to get all row data in edi

2019-02-24 19:23发布

问题:

I have a jqGrid with 100+ rows that are displayed in Edit mode by default. I am trying to figure out a way to send all row data in one call to the server.

The problem - How to get the row data in edit mode (getRowData method returns the html)?

Once I get all the row data, I can hopefully parse them in a JSON format and send it to the server via jQuery.ajax() call.

Any help in this regard is greatly appreciated!

回答1:

I can imagine me many ways to implement you requirements. I would describe you the simplest one. It consist from

  • saving of all editing rows. If you use inline editing mode then you need call saveRow for all editing rows. Because saveRow tests internally whether the row in editing and because the most rows (probably even all) are already in editing mode, you can just use getDataIDs to get array of ids of all rows and then call saveRow in the loop for every from returned id.
  • usage of getRowData without parameters or usage of getGridParam to get "data" option.
  • send the data to the server using jQuery.ajax.
  • the last step is optional. You can start editing mode for all the rows.

I think that the above approach is not only mostly easy implemented. It's mostly save, because it works for every editing control (inclusive custom one).



标签: jqgrid