I have an application in which there is an ultraGrid that is having a data table as its data source. At run time, this grid is user editable, and user can make amendments in the data that is displayed on the grid. Now, there are two buttons: 'Save changes' & 'Cancel changes'.When the user clicks on SAVE button, all the amendments will be saved to database, which is fine. But when user clicks on CANCEL button, all the amendments should be reverted back and the grid should display data exactly as in its data source. So, I am looking for the best way to revert back the changes. One way is again set the data source, but this seems to be a bit costly. Is there and alternate way to do this, like is there any inbuilt method or property of ultragird.Thanks in advance.
Hello Sumit,
Thank you for posting in our forum.
In order to implement Save button and Cancel button functionality you need to perform these steps:
1. Set the UltraGrid’s UpdateMode property to OnUpdate. This will prevent populating any changed data in the grid to the back end data source. More about this property you may find by following the next link http://help.infragistics.com/Help/Doc/WinForms/2011.2/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v11.2~Infragistics.Win.UltraWinGrid.UltraGrid~UpdateMode.html
2. In save button event handler call UpdateDataMethod of the grid. This will populate all changes made in the grid to the back end data source. Then call SaveChanges over the data set to save changes in the data base. More about UpdateData method you nay find by following the next link http://help.infragistics.com/Help/Doc/WinForms/2011.2/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v11.2~Infragistics.Win.UltraWinGrid.UltraGridBase~UpdateData.html
3. In cancel button event handler call UpdateData and then call RejectChanges over the data set. This will revert all the changes user has made.
Please find attached a small sample solution implementing this approach.
Please let me know if this is what you are looking for or if I am missing something.