We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to programatically cancel adding a new row

Hi,

I need to be able to cancel adding a new row programatically to achieve the same result as pressing the escape key twice to clear the row completely.

Using the EndEdit() method on SfDataGrid.SelectionController.CurrentCellManager works fine on an existing row which contained data, but doesn't appear to work on a new row.

3 Replies

JN Jayaleshwari N Syncfusion Team July 9, 2015 08:46 AM UTC

Hi Brett,

Thank you for using Syncfusion Products.

We have analyzed your query “How to programatically cancel adding a new row” by using AddNewRowController and its methods. Due to its protection level, you could not use them directly, but you can achieve them by reflection. We have prepared a simple sample based on your requirement. You can download it from the following location.

Sample location : WPF

In the above sample, we have used two buttons – Cancel and Commit AddNewRow. You can get the AddNewRowController using reflection from GridModel. It has CancelAddNew and CommitAddNew methods. CancelAddNew reverts the edited value and cancel the AddNewRow to be added to grid. CommitAddNew commits the entered value and include AddNewRow to grid.
We already have a KB document related to this query. Please refer the following KB link for your reference.
KB link: http://www.syncfusion.com/kb/5099/how-to-do-addnewrow-operations-programmatically-in-the-sfdatagrid

Please let us know if this solution helps you.


Regards,

Jayaleshwari N.



BK Brett Klopfer July 10, 2015 04:31 AM UTC

Thanks very much for your solution.

Is there future chance that these methods will be accessible directly rather than via reflection?


JN Jayaleshwari N Syncfusion Team July 14, 2015 04:04 PM UTC

Hi Brett,

We have analyzed your requirement “To change the protection level of AddNewRowController”. We will change the accessibility of AddNewRowController class as public and these changes will be reflected in our upcoming release 2015 Volume 3.

Please let us know, if you have any other queries.

Regards,

Jayaleshwari N.


Loader.
Live Chat Icon For mobile
Up arrow icon