Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
355
Reset the AddRowTemplate after cancel update
posted

Hi,

 

I'm using a grid with AllowAddNew set to  AllowAddNew.FixedAddRowOnTop and in BeforeRowUpdate I make some validation to decide if changes will be updated in the data source or not. When validation failed I set e.Cancel to true to cancel update, this work fine but the row (that is the add row template) become a non add row template that means  that IsAddRow property return false, even after pressing ESC the row still non add row template and this is a problem for me because I'm setting some row properties based on this propertie.

How can I reset the add row template?

 

Best regards.

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    When you have a TemplateAddRow in the grid, it has no corresponding row in the data source. At this point, IsAddRow will return false - because the row is not actually an AddRow, it's a TemplateAddRow. So there's another property on the row called IsTemplateAddRow that will return true.

    As soon as the TemplateAddRow gets focus, either by clicking on it of tabbing into it, or in code - a row is added to the data source and the row ceases to be a TemplateAddRow and becomes an AddRow.

    When you cancel the row, the row in the data source is cancelled and remove and thus the row returns to it's original state where it's a TemplateAddRow and not an AddRow any more.

    So it sounds like maybe your code needs to check for IsTemplateAddRow as well as IsAddRow.

Children