Telerik Product and Version
|
ASP.net AJAX 2017 R2 |
Supported Browsers and Platforms
|
Any that ASP.net AJAX supports |
Components/Widgets used (JS frameworks, etc.)
|
RadGrid |
PROJECT DESCRIPTION
I often find that I need to have a grid column that allows multiple forms of text input when editing. For example, I might need to have a password entry, or allow for multiple lines. The best part of this example is that as browsers get better at supporting entries like numbers and date/time, this code will automatically adapt itself.
Here is the code:
public
class
GridTextBoxColumn : GridBoundColumn
{
#region CTOR
public
GridTextBoxColumn()
{
}
#endregion // CTOR
#region PROPERTIES
public
TextBoxMode Mode
{
get
;
set
;
}
#endregion // PROPERTIES
#region IMPLEMENTATION
protected
override
IGridColumnEditor CreateDefaultColumnEditor()
{
GridTextBoxColumnEditor editor =
new
GridTextBoxColumnEditor(
this
);
editor.TextBoxMode = Mode;
return
editor;
}
#endregion // IMPLEMENTATION
}
To use this, put this class in a DLL and then reference it like you do for the regular Telerik controls in your web.config:
<
pages
>
<
controls
>
<
add
tagPrefix
=
"mycode"
namespace
=
"MyCode.Controls"
assembly
=
"MyCode"
/>
</
controls
>
</
pages
>
The, in your grid, just create a column in your Columns collection like this:
<mycode:GridTextBoxColumn Mode="Password" />