Hi,
I have an XamDataGrid in XamDialogWindow (which is used for MDI replacement). I would like to prompt user to save the data before dialog window is closed and I would like to track the situation when user is in grid's edit mode and adding a new record. I would like to update the new value before exit. I created some boolean variable, set it to true on grid's EditModeStarted event and clear it on EditModeEnded. Then on WindowStateChanging event for XamDialogWindow I check the variable, and if grid.ActiveCell.Record.IsAddRecord == true, I try to execute EndEditModeAndCommitRecord command by the grid. As far as I can see, nothing happened, underlying data binded collection still has 0 records. What can be wrong ?
Thanks,
Ed
Hello,
I am just checking if this is still an issue for you and if you could provide more details on the matter.
Hi Eduard,
I have been looking into your scenario and I am not sure that I follow it correctly. It seems that updating the grid in code-behind is not an option for you as you are using MVVM. In this case using a behavior to process the update could be a useful approach. Would you please let me know what do you mean by sending messages to execute the command? Could it be possible for you to modify the attached sample or provide another one that better illustrates the behavior on your side so I could look into it in detail? Thank you in advance.
Hi Maria,
Thanks for the sample. As far as understand it would be just moving grid events processing to separate behavior class instead of code behind. However I would still need to call (somehow) some behavior method from my view model to do something with XamDataGrid - in my case to execute command. And I don't know how it can be done except sending messages.
Hello Eduard,
A behavior could be used to add your custom logic and execute the EndEditModeAndCommintRecord separately (not in code-behind). You may have a look at the following forum thread where Valerie has suggested similar approach and provided a sample project that illustrate the solution: http://es.infragistics.com/community/forums/p/67749/343013.aspx#343013. I believe the example will be helpful for you as well.
It's almost works for me...The problem is - application is using MVVM. View model can receive couple of messages which request to save current data and in each case I would like to track and fix unsaved data. In my case I have save message and search screen message to load another set of data. I cannot execute grid's command EndEditModeAndCommitRecord from the view model. The only thing I can imagine - subscribe on some incoming message on code behind level, process it (i.e. send EndEditModeAndCommitRecord message to grid, ask user for confirmation) and then send different message to view model.