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
430
Problems checking the data in a grid row
posted

When a user clicks off of a row or does a save I need to check the data that is in the row before committing the data to the datatable.

If I use BeforeRowUpdate, detect a problem then e.cancel the entire datarow gets backed out.

What is the best practice for doing this type of data check?

Parents
No Data
Reply
  • 21795
    Offline posted

    Hello Mike,

    UltraGrid allows you to check user input in several ways. Depending on how you need to save the data from the grid to its data source you may validate input per cell, per row or on entire grid. So, depending on your application logic you need first to set UltraGrid’s UpdateMode. Then you may validate user input by handling:

    • BeforeCellUpdate event. In this event you may check the new value. If it is ok proceed further, if not you may cancel the event. Other approach is to save a reference to the edited cell and set some Boolean flag showing if the new cell value is ok. Then if the cell’s value is not correct cancel BeforeCellDeactivate event and put the cell in edit mode;
    • BeforeRowUpdate event. If you use this approach you may need to save the cells’ values in some collection. Cancel the event if there are any incorrect cells. Restore the values of correct cells and ask the user to improve the incorrect ones. You may set some appearance to the incorrect cell or use some other approach.

    You can also save the data only when UpdateData is called over the grid. If this is your scenario you will need to check each cell in the grid before call UpdateData. If there are any invalid cells, ask the user to improve them and update data source after all cells are ok.

    If you give me some additional information about your scenario I will try to give you solution to your issue.

    Please let me know if you have any additional questions.

Children