GridColumn that supports multiple textbox styles

Thread is closed for posting
2 posts, 0 answers
  1. 87BEF4AE-6C13-4B1A-A589-6C9695CE7BC8
    87BEF4AE-6C13-4B1A-A589-6C9695CE7BC8 avatar
    18 posts
    Member since:
    Mar 2015

    Posted 21 May 2017 Link to this post

    Requirements

    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" />

  2. 4513861F-C564-42D2-BC9F-5FAED19E993E
    4513861F-C564-42D2-BC9F-5FAED19E993E avatar
    4090 posts
    Member since:
    Apr 2022

    Posted 24 May 2017 Link to this post

    Hi,

    Thank you for sharing your specific approach with our community. I've updated your Telerik points as a token of gratitude.

    I just want to insert a general caveat here that using custom controls is beyond our support scope, even when they are inherited directly from Telerik controls:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/inheritance/inheriting-grid-columns

    Another approach to achieve this requirement is to use a GridTemplateColumn:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/columns/column-types#gridtemplatecolumn

    Regards,
    Eyup
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.