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 didn't *exactly* do that, but maybe what I did could be useful...
I've got a popup control with a series of editors that match up to the columns in the grid. Then all I did was bind their values to the actual values in the cells and provided a button column to enable the user to trigger the popup. As far as adding new rows is concerned, thats just a little hocus pocus in detecting that the user clicked the button on the AddRecord instead of an existing data item and instead of immediately popping up the edit form, programmatically inserting a new object into my underlying data collection at position 0 and letting the user edit that.
Its far from elegant, but thus far seems to work for us in our proof of concept application.
HTH
Hi,
I was trying to do something very similar. I am trying to load a textbox with values from a selected record of the xamdatagrid cell. So when I type into the text box it adds a row into the xamdatagrid and the datasource to which it is bound. On edit of a row the values should be populated in the text box. From this post I see that you have alreday done that. Just wanted to know how you went about it.
After fighting it as much as possible, I've got the result I wanted by inserting a new object into the source collection at the first position (since this is what tabbing through the add record would do) and then manually setting the ActiveRecord to be the record at position 0 before displaying the popup form, which is already bound to the values of the ActiveRecord.
_modelManager.Models.Insert(0,new Model());modelGrid.ActiveRecord = modelGrid.RecordManager.Current[0];
It feels a little dirty, but it did get the job done.
Thanks, tbeaulieu for starting me thinking down a path that I probably wouldn't have got to for a while longer
That's interesting. I've never worked with cells (data from the grid). All my work has been done through the domain objects that the grid is bound to. I'm not a fan of inline editing in grids. Obviously, it depends on the situation, but I usually have a few fields in the grid and a larger set in an edit form. I use the grid to display, select and initiate actions that I handle. I do have a simplistic scenario where the user edits directly in the grid, but sure enough ... the grid seems unable to cope with IDataErrorInfo, so in that single scenario where I chose to use the grid I have no support for validation. Maybe there's a way. I noticed another post asking that very question. Hopefully we'll get an answer.
Unfortunately, there isn't much code to sample. All I did was to follow the example from the online documentation here: http://help.infragistics.com/Help/NetAdvantage/WPF/2008.1/CLR3.X/html/xamDataGrid_Accessing_Cell_Values_in_the_Active_Record.html with the exception of putting the set of controls in a popup instead of a static area above the form.
That example doesn't address the AddRecord at all, and so I've been blindly trying to find ways to hook into the add new feature, without success. I was hoping that this statement from the end of the walkthrough would mean it would work, but obviously it does not: 'If you modify a value in a TextBox and the TextBox loses focus, the value in the corresponding Cell will also update.'
Your comment about when the grid actually creates the underlying object makes me wonder if I need to be focusing on when the edit button gets clicked in the first place (as my edit button is in a grid column) as opposed to the accept/ok button on the popup.