MultiCombBox Column Not Saving Selection

1 Answer 79 Views
GridView MultiColumn ComboBox
Todd
Top achievements
Rank 1
Todd asked on 28 Aug 2023, 01:20 AM

I am using a MultiComboBox column in a grid to display attribute types. This is the code to add the column:

                GridViewMultiComboBoxColumn col = new GridViewMultiComboBoxColumn("");
                col.DataSource = maintenance.AttributesTypesSelectAll();
                col.DisplayMember = "attributetype";
                col.ValueMember = "attributetypeid";
                col.FieldName = "attributetypeid";
                col.HeaderText = "Type";
                this.grdAttributes.Columns.Add(col);

This is the code to show the correct editor when the column is selected:

       private void grdAttributes_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
        {
            if (this.grdAttributes.CurrentColumn is GridViewMultiComboBoxColumn)
            {
                if (!this._isColumnAdded)
                {
                    this._isColumnAdded = true;

                    RadMultiColumnComboBoxElement editor = (RadMultiColumnComboBoxElement)this.grdAttributes.ActiveEditor;
                    editor.EditorControl.MasterTemplate.AutoGenerateColumns = false;
                    editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("attributetype"));
                    editor.EditorControl.Columns["attributetype"].HeaderText = string.Empty;
                    editor.AutoSizeDropDownToBestFit = true;
                }
            }
        }

This works correctly and maps the column to the right value when the column is loaded, but when I edit the column or add a new column it doesn't retain the value. I feel like I'm missing a step but just not sure what at this point. What is the correct way to use a MultiComboBox in a RadGrid to show the text assoicated with an ID field rather than the ID, and then retain that value on add/edits.

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 29 Aug 2023, 11:26 AM

Hi Todd,

Thank you for the provided code snippet.

Upon checking the code I could not find anything specific which could break the configuration. You can double-check if all properties set to the GridViewMultiComboBoxColumn column are set correctly. I have also created a sample project using your code snippet and the column is mapped correctly. You can check the project and let me know if I am missing something from your setup.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Todd
Top achievements
Rank 1
commented on 29 Aug 2023, 01:05 PM

Turns out the step that I was missing, was not adding the attributeid column to the MCCB on edit. Once I added that (and marked is isvisible=false) everything mapped correctly and retained the value. I mistakenly thought that even if I didn't add the column it was still 'there' in the data.
Tags
GridView MultiColumn ComboBox
Asked by
Todd
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or