Telerik Product and Version
|
ASP.net AJAX 2017 R2 |
Supported Browsers and Platforms
|
Same as Telerik ASP.net AJAX |
Components/Widgets used (JS frameworks, etc.)
|
RadGrid |
PROJECT DESCRIPTION
I find that my users do not like checkbox columns very much. I find that they much prefer a Yes/No to be displayed instead as well as being able to select Yes or No when editing. That is why I wrote the GridYesNoDropDownColumn. It's actually quite simple as shown below. I hope you find this as useful as I have!
public
class
GridYesNoDropDownColumn : GridDropDownColumn
{
#region CTOR
public
GridYesNoDropDownColumn()
{
this
.ColumnValidationSettings.RequiredFieldValidator.InitialValue =
"*"
;
this
.ListTextField =
"Value"
;
this
.ListValueField =
"Key"
;
this
.DropDownControlType = GridDropDownColumnControlType.DropDownList;
}
#endregion // CTOR
#region IMPLEMENTATION
/// <summary>
/// Sets the drop down list's data source
/// </summary>
/// <param name="inItem"></param>
protected
override
void
SetDropDownListDataSource(GridItem inItem)
{
GridDropDownColumnEditor editor = (GridDropDownColumnEditor)
this
.CurrentColumnEditor;
Dictionary<
bool
?,
string
> data =
new
Dictionary<
bool
?,
string
>();
if
(
this
.EnableEmptyListItem)
data.Add(
null
,
""
);
data.Add(
true
,
"Yes"
);
data.Add(
false
,
"No"
);
editor.DataSource = data;
base
.SetDropDownListDataSource(inItem);
}
#endregion // IMPLEMENTATION
}