I have a GridViewTextBoxColumn in my grid. I want it to behave like a drop down when I have more than one potential value which could be displayed. In order to do this I capture the "EditorRequired" event. Sometimes I will have values in my grid for a given row and sometimes I will not. Sometimes I will have only one item in the row as well. So basically I expect to have no value, one value or multiple values.
I'd like the column in my GridView to only show the drop down list when I have more than one value that is available. Currently the column shows the drop down as soon as I click on that column which is very misleading to the user. I've attached 3 screen shots showing an example of how my grid row/column appears. In my screen shots I also show an exclamation point image when there is more than 1 item in my drop down list.
Here is my implementation of this event..
private void BatchComparisonGridEditorRequired(object sender, EditorRequiredEventArgs e)
{
if (BatchComparisonGrid.CurrentColumn.Name == "Matches")
{
// get model
ComparisonScanViewModel model = BatchComparisonGrid.CurrentRow.DataBoundItem as ComparisonScanViewModel;
RadDropDownListEditor editor = new RadDropDownListEditor();
RadDropDownListEditorElement element = editor.EditorElement as RadDropDownListEditorElement;
element.DropDownStyle = RadDropDownStyle.DropDownList;
element.DataSource = model.Matches;
element.DisplayMember = "Id";
// only 0 or 1 match?
if (model.Matches.Count <= 1)
{
// how to not make this a drop down??
}
// more than 1 match? make it obvious
if (model.Matches.Count > 1)
{
element.BorderThickness = new Padding(1);
element.FocusBorderColor = Color.Blue;
element.EnableFocusBorder = true;
}
// assign as the editor
e.Editor = editor;
}
}
Also, it would be nice for the border of the column to have a thickness and color before clicking on it when it has multiple values in the drop down. If possible please let me know how to do this.