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
405
BeforeExitEditMode and CellClickButton advice
posted

Hello, I'm wondering what your thoughts are on this situation:

I have a grid that has an "Add New Row" button... all this does is add another object to the bindinglist that the grid is using as a datasource, so immediately the row shows up and I put the cursor in the first cell of the new row in edit mode for their convenience.  I'm using the initializelayout event to add an unbound column called 'Action' that has a delete button in it.  I'm handling the CellClickButton to delete rows from the underlying bindinglist.

I'm also using BeforeExitEditMode to determine if the user has entered valid values.  if they leave a required field blank, I ask them if they are sure and if so, to click 'OK', which will remove the underlying object from the bindinglist, which remoes the row from the grid.

The problem situation is... if they add a new row and before entering any data, the cursor goes to the first cell of the empty row, but they click the "Delete" button for that row... my BeforeExitEditMode event fires, as expected because the cursor left the first cell... it then prompts them if they are ok with removing the row, and if you click yes, it removes the row and then crashes... presumably because the CellClickEvent then fires, but is invalid because the object doesn't exist anymore.

What are your thoughts on this situation?  I may need to cancel the CellClickButton event somehow... but not sure how to do that. 

Thanks

Rocky