This is specifically to having a DataView as the underlying datasource, and, specific to the comma char. I can type all I want, letters, numbers, spaces, or going back, but the comma character (and possibly other non-alpha chars, although I haven't checked them) causes the XamComboEditor to attempt to create a new DataRowView. Since that class has no parameterless constructor, it fails. My understanding is that this should NOT be happening when CustomValueEnterAction="Allow".
Hi Adrian,
Thank you for posting to Infragistics Community!
I believe you will find the RequireEmptyConstructor Exception topic of our documentation quite informative on the matter. It is under the grid’s section, however, it is applicable to the XamComboEditor as well, since it is caused by essentially the same thing. The suggested workaround approach is leveraging the XamComboEditor’s DataObjectRequested Event and setting the event arguments’ NewObject variable to a new instance of the object to be added. Additionally, it is required to mark the event as handled. For example:
private void XamComboEditor_DataObjectRequested(object sender, Infragistics.HandleableObjectGenerationEventArgs e) { if (this.table != null && e.ObjectType.Equals(typeof(DataRowView))) { e.NewObject = new DataView(this.table).AddNew(); e.Handled = true; } }
Attached you will find a small sample demonstrating this suggestion. On my side, this resolves the error for the editor having its CustomValueEnteredAction property set to "Allow" or “Add”. Please, test it on your side and if you require any further assistance on the matter, please, let me know.
Best regards, Bozhidara Pachilova Associate Software Developer
3010.XCEDataView.zip
What I'd like to do is not add to the collection at all while the user is typing or when the control loses focus, since the underlying row would require some user input to fill out correctly. I was set up with both DataObjectRequested (handled = True) and ItemAdding (w/ cancel = True) events to try to avoid this. While can bypass the initial error by assigning a value to e.NewObject in DataObjectRequested, I still get an error unless I fill the DataRowView with some unique data to satisfy the underlying tables' referential integrity.
Is there some way, other than setting CustomValueEnteredAction to 'Ignore' (which prevents the user from entering data not in the list)? That I can avoid adding a DataRowView? The idea is that the user would be able to use a button to add the new item to the collection (via a dialog where they can enter all necessary data), with some of the data taken from the unmatched text in the XamComboEditor
I believe the suggested approaches are an exhaustive list of the ways to address this. The “Add, Allow, Ignore” are also the available options for the behavior on user input.
While I understand that creating an empty DataRowView object causes errors due to constraint violations in the underlying data tables, the approach involving assigning temporary unique values and altering them after the user fills in the necessary information sounds viable given the scenario.
While it is possible that I might be missing some aspects of the scenario, I modified the previous sample, so that a second column is added to the DataTable having its “AllowDBNull” property set to ‘false’ as a sample constraint. The DataObjectRequested handler remains the same, however, the ItemAdding and ItemAdded events are leveraged to intercept the process and collect user input for that second column. After filling the data, the combo editor’s text is cleared and the proper data item is added to the underlying data source. I am attaching the sample below and I hope it helps in implementing the target workflow.
If this is not an accurate demonstration of what you are trying to achieve, please, modify the sample with only relevant code and send it back to me along with further details, so I can investigate other potential approaches. Thank you for your cooperation.
Best regards, Bozhidara Pachilova
1524.XCEDataView2.zip