I have a observablecollection binding to the grid datasource. I add records by insert element into collection. I found I can not use the undo to remove an added records. Who know how can I do it?
Undo operation works only when you add the new record through the AddNewRecord functionality of the grid. In order to make this works when you add directly to the collection, you can listen to the CollectionChanged event of the ObservableCollection and delete the new added object when it doesn't meet any creterias. You can also obtain the DataRecord that is generated from the grid and use the undo operations as well. Please, check the attached sample and let me know if this works for you.
I use 10.1. With the demo I found I can add the record but I can not undo the added records. I checked online help of 10.1. There is no AddNewRecord function. But it mentions that the datasource should implement IBindingList.
On the other hand, I need to add record in the middle of collection not only at the begin or the end. It looks AddNewRecord can not control the position of the new record.
I use 10.2. But I get the same result.
For undo/redo the edit operations in the cells please, take a look at the Undo-Simple and Undo-Advanced samples from our Feature Browser. You can also find this article helpfull:
http://blogs.infragistics.com/forums/p/37758/218798.aspx
My requirement is an Undo command which can undo the user edit operation. I need to undo the operation which is done especially add new record in the middle of collection. To catch the events can not satisfiy it.
Yes, the undo operations works fine when you add new records to the grid using the UI functionality of the grid. If you need to add items directly in the collection then you might consider using some of the events exposed by the collection like CollectionChanged, ListChanged etc. and disable adding of the new item as shown in the attached sample.
Let me know if you need any further assistance on this.
First of all, I think I can undo the new record added in AddNewRecord area.
Secondly, do you mean I need to add record in AddNewRecord area to make the operation revocable? Is it possible undo the new record without AddNewRecord area?
In order to make the Undo operations works with the AddNewRecord functionality, you will need your datasource to implement IBindingList interface. Also please make sure you have an empty constructor in your object class and setters defined on each public properties.
Let me know if you can manage to solve this issue.