Grid Yes/No Column

2 posts, 0 answers
  1. Decisive Computing
    Decisive Computing avatar
    18 posts
    Member since:
    Mar 2015

    Posted 21 May 2017 Link to this post


    Telerik Product and Version AJAX 2017 R2

    Supported Browsers and Platforms

    Same as Telerik AJAX

    Components/Widgets used (JS frameworks, etc.)


    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;
            #endregion // IMPLEMENTATION
  2. Eyup
    Eyup avatar
    4046 posts

    Posted 24 May 2017 Link to this post


    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:

    Another approach to achieve this requirement is to use a GridTemplateColumn:

    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.