is there an example of using jqgrid's getChangedCells method to determine if data has changed?
I grepped getChangedCells in the downloadable demos for jqgrid, and could only find the function definition, not example usages of getChangedCells.
What I want to do is save the edits that a user's made if the user clicks on another row. But, I only want to submit the save if the row is dirty.
Thanks in advance, --Nate
There are no safe dirty flag on the row. You can use the fact that at the beginning of row editing (at the start of the inline editing mode) the method editRow add editable="1"
attribute to the grid row (<tr>
element). Later the methods saveRow and restoreRow changes the attribute value to editable="0"
. So the rows of the current page which was at least once in the inline editing mode will have the editable
attribute. If the id of the table element is "list" you can find the edited rows with
$("#list tr[editable]")
The ids of the elements of the set are the rowids of the rows.
If you use paging in the grid you should be careful and save the ids of the edited rows on the current page before the changing of the page. The onPaging event would help you here.
In my opinion the best and the most safe way to do what you need is to use aftersavefunc
parameter of the editRow or saveRow methods (probably you use directly only editRow). Inside of your aftersavefunc
function you can save the id of the modified row in an array/map. This will solve your problem and will safe work.