We are using the jQuery('#grid').editRow()
feature of jqGrid, that allows you to edit fields in a row inline.
Does jqGrid support inline editing of multiple rows at once, where I can make changes on multiple rows and then submit all at once?
We are trying to avoid having to make changes to each row one by one and do a separate "round trip" to the server to commit each time, for cases were we want to bulk edit a number of fields for a number of records and have a single "commit".
Inline editing of multiple rows is not implemented by jqGrid. You can use local editing and post all the changes to the server manually, but you will have to implement the submit of all changes yourself.
I personally would not implement such behavior in my projects. The reason is that I think that the web site should always support concurrency (optimistic concurrency have the most sense). In the case if one person try to submit the changes to the server, the server can answer with the concurrency error: some other person have already modified the data. In the case the grid data should be refreshed and the editing of row should be repeated. I see problems with implementing of editing of multiple rows in case of the usage of optimistic concurrency. How would the error messages look like? If many rows are changed how the error message should look like? What should the user do in case of error? Should he/she repeat the full changing of the data? Where are the benefit from the users point of view?
The submitting of the editing of one row was almost immediately in all jqGrid implementations which I had. So I see no need to do multiple rows at once in the projects. Disadvantages for the user in case of concurrency errors are larger as advantages from "round trip" reduction. Because of very good connection to the server the sending of the data is not a problem in environments of my customers.
Inline editing of multiple rows is not possible in original JQGrid implementation. What the original implementation does is, every row which you edit and lose focus will be submitted.
Instead, create a custom implementation like this: 1. Override(Extend) the existing grid.inline.js and write your own edit rows and save rows. 2. In the edit rows function, configure in such a way as to add the dirty rows (edited) to be collected separately. 3. In the save rows function, you can submit only the dirty rows to the server.
And for preventing the concurrent updation of same data, you can have version control mechanism in either of the following ways: 1. Have a version field (hidden) for all the rows. When a row becomes dirty, increment the version field. 2. When submitting the rows, check for the version number existing and the new one. If there is a mismatch, intimate to the user/ update the existing. (This, you can implement quite easily)
That's it! Hope that was useful! :-)
I don't know very much jqGrid, however I made this simple test (I might be missing something):
Run this code manually:
jQuery("#rowed1").jqGrid('editRow', '11');
jQuery("#rowed1").jqGrid('editRow', '12');
jQuery("#rowed1").jqGrid('editRow', '13')
Edit the three rows
Run this code manually:
jQuery("#rowed1").jqGrid('saveRow', '11');
jQuery("#rowed1").jqGrid('saveRow', '12');
jQuery("#rowed1").jqGrid('saveRow', '13');
Of course the url parameter is required and I think you could use the callback
option to gather all the edited rows.
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With