Hi,
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;
this.gridView.Columns.Add(col);
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[] {
colCode,
colName});
editor.AutoSizeDropDownToBestFit = true;
FilterDescriptor filterDescriptor = new FilterDescriptor();
filterDescriptor.PropertyName = "Name";
filterDescriptor.Operator = FilterOperator.Contains;
editor.EditorControl.MasterTemplate.FilterDescriptors.AddRange(new FilterDescriptor[] {
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.
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;
this.gridView.Columns.Add(col);
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[] {
colCode,
colName});
editor.AutoSizeDropDownToBestFit = true;
FilterDescriptor filterDescriptor = new FilterDescriptor();
filterDescriptor.PropertyName = "Name";
filterDescriptor.Operator = FilterOperator.Contains;
editor.EditorControl.MasterTemplate.FilterDescriptors.AddRange(new FilterDescriptor[] {
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.