RadMultiColumnComboBoxElement AutoGenerateColumns not working

3 posts, 0 answers
  1. Saif
    Saif  avatar
    30 posts
    Member since:
    Apr 2014

    Posted 06 May 2014 Link to this post


    Im trying to bind datatable in GridView GridViewMultiComboBoxColumn

    GridViewMultiComboBoxColumn col = new GridViewMultiComboBoxColumn();
          col.DataSource = dtCash;
          col.DisplayMember = "Name";
          col.ValueMember = "td";
          col.FieldName = "Id";
          col.Name = "Description";
          col.HeaderText = "Name";
          col.DropDownStyle = RadDropDownStyle.DropDown;

    bool isColumnAdded;
        private void gridView_CellEditorInitialized(object sender, GridViewCellEventArgs e)
          if (this.gridView.CurrentColumn is GridViewMultiComboBoxColumn)
            if (!isColumnAdded)
              isColumnAdded = true;
              RadMultiColumnComboBoxElement editor = (RadMultiColumnComboBoxElement)this.gridView.ActiveEditor;
              editor.AutoFilter = true;

              editor.EditorControl.MasterTemplate.AllowAddNewRow = false;
              editor.EditorControl.MasterTemplate.AllowCellContextMenu = false;
              editor.EditorControl.MasterTemplate.AllowColumnChooser = false;
              editor.EditorControl.MasterTemplate.AutoGenerateColumns = false;
              editor.EditorControl.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
              editor.EditorControl.MasterTemplate.AllowRowResize = false;

              GridViewTextBoxColumn colCode = new GridViewTextBoxColumn();
              GridViewTextBoxColumn colName = new GridViewTextBoxColumn();
              colCode.FieldName = "Code";
              colCode.HeaderText = "Code";
              colCode.Name = "Code";
              colName.FieldName = "Name";
              colName.HeaderText = "Name";
              colName.Name = "Name";
              colName.IsVisible = false;
              editor.EditorControl.MasterTemplate.Columns.AddRange(new GridViewDataColumn[] {
              editor.AutoSizeDropDownToBestFit = true;

              FilterDescriptor filterDescriptor = new FilterDescriptor();
              filterDescriptor.PropertyName = "Name";
              filterDescriptor.Operator = FilterOperator.Contains;
              editor.EditorControl.MasterTemplate.FilterDescriptors.AddRange(new FilterDescriptor[] {

    I Set the AutoGenerateColumns to true to show only two columns i want.. but when i run, all columns coming from the datable also shows.

    I dont know exactly what is wrong with my code.
  2. Dimitar
    Dimitar avatar
    1871 posts

    Posted 07 May 2014 Link to this post

    Hello Saif,

    Thank you for writing.

    In this case you should use the CellBeginEdit event instead of CellEditorInitialized, because in the second the underlying grid is already initialized and it already has some columns. Detailed information is available in the following article: GridViewMultiComboBoxColumn.

    Also please note that the column that is used as ValueMember should exist in the underlying grid even if it is not visible. 

    Let me know if you have additional questions.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
  3. Saif
    Saif  avatar
    30 posts
    Member since:
    Apr 2014

    Posted 10 May 2014 Link to this post

    Thanks Dimitar
Back to Top