Hi,
We have a grid which has one field which is "editable" but when you enter the edit mode on it a dialog pops up. The results of the dialog are processed and the Cell.Value is set appropriately. For records in the NewRecord row, if this happens to be the only field selected, the RecordAdding event doesn't trigger. When we go to process the ViewModel.Save() method (which attempts to automatically add records as part of the save), it doesn't recognize the NewRecord row as part of the DataGrid. With any other field a key press triggers RecordAdding and it's recognized in the grid, but because of how we handle this particular field it isn't handling appropriately.
I'm wondering how I can alter the cell behind the scenes in the dialog processing so that RecordAdding fires without any keyboard input from the user.
Thanks
Hello Danielle,
Thank you for choosing Infragistics.
I have been looking into your issue and in order for me to assist you the best way possible I would like to ask you a couple of questions. Would you please provide me with more detailed information on the functionality and behavior you want to achieve in your project? Would you also please send me a sample application of your project where the issue you have described is being reproduced? Having this information would help me further investigate this matter for you.
If you need any further assistance on this matter, please do not hesitate to ask.
This is the desired workflow.
Right now, instead of 4, the grid keeps the value in the new row and the unsaved indicator goes away, signalling a successful save. The fact that the values are still in the new row in addition to the signal going away is confusing and might imply success, since no specific error is thrown.
I'll work on a sample this afternoon.
Thank you for your feedback.
I have been looking further into your issue and I believe I have come up with a certain approach I can suggest you so you can achieve the functionality you are looking for. I have prepared a sample application for you to test and see if the desired effect is achieved. In the CellActivated event of the XamDataGrid I am creating an instance of a sample dialog and an event handler for it’s “Closed” event. I am also setting the Cell’s value to the value of the TextBox from the dialog. When the “Closed” event of the dialog fires, it adds a new record to the XamDataGrid with the current populated information. However, this approach would allow only one cell of a record to be populated before it is committed as a new record and changes to already existing records in the XamDataGrid will also result in adding a new empty record.
Hi Tacho,
That's not really the behavior that we're going for. There are several required fields, and under a normal Enter Key/Add Button the user would be prevented from adding the record without the required fields.
I think the best solution to our problem here is to trigger the RecordAdding event so that the record is included in the DataView.Records as IsAddRecord at DataView.Records[0] (our add row is at the top). We can then attempt to add the DataView.Records[0] to the DataView.Table.Rows collection. Assuming it passes all null checks, it will be added to the grid. The problem is that I'm having trouble triggering the RecordAdding event, because it seems to only be triggered if the user actually physically types into the fields of the new row, which in this case they do not do because the dialog sets the value when it's Closed event fires.
Thank you for the detailed information you have provided.
I have done some further research on your issue and it seems that the RecordAdding event of the XamDataGrid cannot be fired according to the behavior you have explained in your previous post. In order to fire an event in code-behind the event handler must be invoked by passing it's corresponding EventArgs as a second parameter. The second parameter of the RecordAdding event handler is an instance of the RecordAddingEventArgs class which does not have a public constructor and so cannot be instantiated. This leads to the inability of firing this particular event in code-behind. An approach I can suggest to you is to manually commit the new record as shown in the code snippet below which applies to the sample application I have provided in my previous post.
(MyXamDataGrid.RecordManager.CurrentAddRecord.Cells.ElementAt(0) as Cell).Value = "John Doe";
(MyXamDataGrid.RecordManager.CurrentAddRecord.Cells.ElementAt(1) as Cell).Value = 40;
MyXamDataGrid.RecordManager.CommitAddRecord();
The CurrentAddRecord is a property I was not aware of, I can definitely craft a similar solution with this.
Thank you!
Thank you for your feedback. I am glad to know I was able to help you with your issue. I believe this thread can help other people looking for a similar solution.
If you require any further assistance on this matter, please do not hesitate to ask.