Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
XamComboEditor RequireEmptyConstructorException when CustomValueEnteredAction="Allow"
posted

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". 

Parents
  • 2680
    Offline posted

    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

Reply Children
  • 2680
    Offline posted in reply to Adrian Abshere

    Hi Adrian,

    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