How to Select Multiple Items in a Dropdown List in GridGroupingControl
I have a setup where a cell in the GridGroupingControl displays a dropdown list. The issue is that this list only allows selecting a single value. Now, I want to modify it so that the dropdown includes checkboxes, allowing me to select multiple items freely.
Below is my initial code and an illustrative image.
DataTable dt = new DataTable();
private void CreateDataTableMaChamCongDTO()
{
dt = new DataTable();
dt.Columns.Add("Mã chấm công", typeof(System.String));
dt.Columns.Add("Tên chấm công", typeof(System.String));
dt.Columns.Add("Tỷ lệ tính lương", typeof(System.Decimal));
dt.Columns.Add("Tỷ lệ trừ phép", typeof(System.Decimal));
foreach (var row in Data.MaChamCongDTO)
{
dt.Rows.Add(row.MaChamCong_ud, row.MaChamCong_nm, row.TyLeTinhLuong, row.TyLeTruPhep);
}
}
grd.TableDescriptor.VisibleColumns.Add(columnName);
grd.TableDescriptor.Columns[columnName].HeaderText = _header;
grd.TableDescriptor.Columns[columnName].Width = 50;
grd.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.CharacterCasing = CharacterCasing.Upper;
//Assigning the column cell types as GridListControl
grd.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.GridListControl;
//Enables Autocomplete
grd.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.AutoCompleteInEditMode = GridComboSelectionOptions.AutoSuggest;
grd.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.ShowButtons = GridShowButtons.ShowCurrentCell;
//Add DataSource
grd.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.DataSource = dt;
grd.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.DisplayMember = "Mã chấm công";
grd.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.ValueMember = "Mã chấm công";
You can achieve multi-selection by using a GridComboBoxListBoxPart with checkboxes or a GridDropDownListCellModel. Setting ExclusiveChoice to false allows multiple selections. Have you tried handling selected values as a comma-separated string?
My problem is also solved, thank you so much.
My problem is also solved, thank you so much. scmapk