Hi!
I'm unable to figure out how to do persist a update into my server. I've not found any good examples on how to use the "saveChanges" functionality. From the blogpost here: #mce_temp_url# I found that returning a "Success" = true, should clear the transaction log, but it does not seem to do it. (but I might have misunderstand how it should work)
So, here are my questions:
As you can see from my question I'm a bit confused on how to do this. I found no good documentation describing this functionality.
Thanks for any help
Larsi
Hi Larsi,
=> * Calling commit() on the grid does not remove italic. Should it?
It should, but unfortunately didn't in the released version (#1023). The fix for this has been included in the new Service Release (build #2045) - should be up for download very soon (today or tomorrow if I'm not mistaken).
=> * Calling saveChanges, and returning {"Success":true} does not remove italic. Should it?
Calling saveChanges() removes the "dirty" styling (italic (updated or added) or strike-through (deleted) ) from the affected grid cells - this is included in the released version of the igGrid.
If it doesn't then there might be a problem which should be investigated.
=> * Calling saveChanges, and returning {"Success":true} does not clear transaction log, that is, the same changes are sent over and over. Should it?
Yes, it should and it does so - you can verify this with the help of the "Batching Updates" sample which Angel pointed out in his reply.
(http://samples.infragistics.com/jquery/grid/batching-updates)
As you can see from the code of the View (in the Code View section of the sample), only the saveChanges() method is used when the "Save Changes" button is clicked. Visually, you can confirm that the "dirty" styling (italic or strike-through) is removed.
However, you can also verify that the transaction log is cleared as well - you can open the debug tools of your browser and use the allTransactions() method of the igGrid (http://help.infragistics.com/jQuery/2011.2/ui.igGrid#!methods )
$('#grid1').igGrid('allTransactions')
to see that all transactions in the log are removed and none are left pending.
If you still encounter this problem, can you please send us a mock-up project so we can investigate?(Also, a screenshot of the response of a POST request to your UpdateUrl would also help)My personal guess is that the controller action that handles the update might not be configured correctly, so returning {"Success": true} as a part of the response doesn't make it into the View (and the grid) correctly.Hope these bits of information help you out.
Cheers,Borislav
Great! Thanks for your detailed answer.
A few follow ups:
* Calling commit() on the grid does not remove italic. Should it?
* Calling saveChanges, and returning {"Success":true} does not remove italic. Should it?
* Calling saveChanges, and returning {"Success":true} does not clear transaction log, that is, the same changes are sent over and over. Should it?
Thanks again for looking into this
I hope you are using 11.2 , and not 11.1 (because this functionality is not present in 11.1).
You can start by taking a look at this sample:
http://samples.infragistics.com/jquery/grid/batching-updates
Have a look at the View's javascript code, and then at the following controller action: EditingSaveChanges.
as for handling Success vs failure, since saveChanges is async, it attaches event handlers internally, so that when the response comes back from the server (with either Success true or false), it calls commit respectively.
I will try to answer your specific questions:
=> To persist a update to a row, what should I do ?
It depends if you want immediate updating, or batch updating. if you'd like an update to be triggered after every row editing, then you can handle rowUpdated, and call saveChanges(). Note that updating is on two levels in the grid. depending on the value of autoCommit. If it's true, changes are automatically updated on the client data source (no italic font) , but you still have to call saveChanges so that they are propagated to the server as well. If you'd like batch updating, you can have any UI (such as a button), which calls saveChanges, whenever some rows are updated - depending on your application logic. if you are using the saveChanges API, you don't need to post anything manually. Also please note that a prerequisite of this is to set the updateUrl to the controller action which does the actual persistence. the Batch updating sample i have referenced above has this.
=> To commit changes to the client ?
If autoCommit is true, then those changes are commited automatically (and therefore no italic fonts are applied for modified cells or rows)
If autoCommit is false, you can call commit() using either rowupdated / cellupdated or using some specific UI in case you are having a batch updating scenario
=> What about the transaction log?
Save changes sends a serialized JavaScript array of transaction objects, which contain the row id (primary key), and a list of the modified row values. it only sends the modified data, not the whole grid data that's currently bound.
Hope it helps. Let me know if you have any other questions.
Thanks,
Angel