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
Setting value of igCombo in igGrid after changing datasource without making dirty


I am trying to use the igGridUpdating with an igCombo. My use case is that i have a 'Category' dropdown and a 'SubCategory' dropdown. When the user selects a category, I fetch the subcategories for that category and populate the subcategory igCombo with those values.

The problem comes up when there is already a value in the subcategory. When I set the dataSource of the subcategory igCombo, the value that is lost and the row becomes dirty. Then when you decide you don't want to change anything and exit or click somewhere else the row thinks you change that subcategory to null and saves that null value. 

I've tried setting that value after i set the datasource but setting the value causes the row to become dirty as well. 

What is the best way to accomplish this?



No Data
  • 17490
    Offline posted

    Hello Erik,

    Thank you for posting in our community.
    I created a small sample illustrating the described behavior. I am using a cascading combo editor providers for "Country" and "City" columns. When a new country is selected the data source for the city combo editor is changed. However, on my side, when I cancel editing all changes are reverted and cell values are going back to their initial values, respectively cells not being marked as dirty. Please keep in mind that igCombo, which is the base for the editor provider, by design does not accept custom values, which means that if the cell value is not available in the combo`s data source the editor will select the first value from the combo items. In this case my suggestion is setting combo editor`s allowCustomValue to "true" and its mode to "editable". This will ensure that if the cell value is not present in the drop down items it will be set as a value for editor`s input rather than lost. For example:

     features.Updating().EditMode(GridEditMode.Row).ColumnSettings(cs => {
           cs.ColumnSetting().ColumnKey("Status").EditorType(ColumnEditorType.Combo).ComboEditorOptions(co => co.DataSource(Url.Action("employee-combo-data")).ID("comboEditor").ValueKey("Value").TextKey("Value").Mode(ComboMode.DropDown));
           cs.ColumnSetting().ColumnKey("Country").EditorType(ColumnEditorType.Combo).ComboEditorOptions(co => co.DataSource(Url.Action("employee-combo-dataCountries")).ID("comboEditorCountry").ValueKey("Value").TextKey("Value").Mode(ComboMode.DropDown).AddClientEvent("selectionChanged", "selChanged"));
           cs.ColumnSetting().ColumnKey("City").EditorType(ColumnEditorType.Combo).ComboEditorOptions(co => co.DataSource(Url.Action("employee-combo-dataCities")).ID("comboEditorCity").ValueKey("Value").TextKey("Value").Mode(ComboMode.DropDown).AllowCustomValue(true).Mode(ComboMode.Editable));

    Observe "City" column editor settings.
    Please have a look at the my sample here. If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me for further investigation along with steps to reproduce.
    Please let me know if you have any additional questions regarding this matter.