Hi
To help ease the transition to a normal data entry model for some legacy users, I'm trying to provide a popup form to allow the user to edit the values of the current row. For the most part, it works fine. I've added a column with a button, and when the user clicks it they get a Popup with controls that are databound to the cells in the row that they clicked. I was very pleasantly surprised about how easily that came together.
The problem I'm having is when the edit button is clicked on the AddRecord. The popup displays normally, and you can fill in the values and see them propogate to the xamDataGrid in the background. When I'm done editing, I press the OK button on my popup form and it sends me back to the grid with all of the values filled into the AddRecord. However, it won't actually move the record into the collection of data rows. Even if I click on one of the cells and tab all the way through the row, the values stay in the AddRecord instead of becoming a new record. The only way I've been able to make it work so far is to manually edit a value while I'm tabbing through the resulting AddRecord. Obviously, what I'd like to have happen is have the new record be automatically added without any tabbing or editing- I'm sure there's an event or command that I'm missing that I should be raising/firing when the OK button is pressed, but I cannot find it.
Thanks for guidance
I do something similar in app I'm currently working on. I don't kno what your binding model is, but for me, I'm going against a collection. In order to add a new record I create an empty domain object and feed it to a dialog window (the view). When the user hits OK, it calls back into the viewmodel to try to persist the object. If successful, the object is then added to the collection, which the grid automatically sees.
I do something very similar for edits. I copy the object using a memento, pass that copy to the view, let the user make changes and then on OK the view calls back into the viewmodel to persist the changes. If successful, the cloned and edited object is then copied back into the original object (which is already in the collection) and BAM... the grid sees the updates.
Letting the user edit an object already bound is not good, in my opinion because it doesn't allow for cancellation. Likewise, seeing a new record simultaneously appearing in the grid before you hit OK is not intuitive.
Of course, this is all based on the use of domain objects, versus going directly against a record set.
Thanks for the reply
We were hoping to make our 'popup' form as lightweight as possible as the intent is to push in-grid editing as much as possible via training. I'm actually pretty okay with the cancel logic working under the model we've started with- that is, you get exactly the same behavior whether you're editing via the grid or via the popup- no special undo functionality is gained (or lost) if you edit via the popup instead of the grid.
Although if I'm not able to come up with a way to notify the grid of what I'd like it to do then I may be forced to go the other route. I am also going against a collection, but I was hoping to avoid touching the collection directly whilst it is bound to the grid.