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
310
BeforeRowUpdate more odd behavior
posted

Hi,

So I am here again, questioning the behavior a bit... thanks again on help with the TemplateAddRow vs. DataTable.NewRow() methods of adding the row. I have switched to the TemplateAddRow method for adding rows so that I can get the BeforeRowUpdate to fire. However, after pounding on it a while, I found that the cancel feature removes everything the user added... so when I validate the row, and one column is in error, I do not cancel the update. This leaves the grid in a precarious state. The user can move to another row, they can move to other controls or grids but really, we want them back on the row editing the value that is not right.

I have tried a number of things to pull them back but nothing seems to work. And the other concern I have, is that even if I can get them back on the row, I found if they change nothing, the BeforeRowUpdate will not fire even though I am in a bad state when they again try to leave the row. Basically, once they have committed to adding a row, I want to insure they get past validation before I will let them save or cancel. Perhaps my approach to this is wrong... perhaps there is a way to control them they way I want... 

I was wondering why setting the ActiveCell of the grid to an item on this row, does not put the user's focus on the cell. It seems like it ought to.

From the BeforeRowUpdate... 

grid1.ActiveCell = e.Row.Cells["FieldName"];

Any thoughts? Thanks,

Kent

Parents
No Data
Reply
  • 23930
    Offline posted

    Hi Kent,

    Thank you for posting in our forums.

    Maybe the BeforeExitEditMode event will be most useful for you in this case. If the user has entered invalid data, or no data at all, you can cancel the event and the cell will remain in edit mode until a valid input is entered.

    Setting just the ActiveCell, will only activate the cell, but it won’t enter edit mode. The following method will bring the active cell into edit mode:

    ultraGrid1.PerformAction(UltraGridAction.EnterEditMode);

    I have attached a sample, which demonstrates the BeforeExitEditMode approach.

    Let me know if you have any additional questions.

    WG_TemplateAddRowAddValidRow.zip
Children