RadGrid GridClientSelectColumn disable checkbox in certain rows

6 posts, 0 answers
  1. Chen Jun Ying
    Chen Jun Ying avatar
    22 posts
    Member since:
    Apr 2010

    Posted 14 Feb 2012 Link to this post

    Hi all,

    How to disable GridClientSelectColumn checkbox in some of the rows? Which grid event shall I look into? How can I reference to the checkbox?

    Thanks
    Chen.
  2. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 14 Feb 2012 Link to this post

    Hello Chen,

    I hope the following code library will help you for your implementation:
    http://www.telerik.com/community/code-library/aspnet-ajax/grid/disable-selection-for-some-rows-in-gridclientselectcolumn-conditionally.aspx

    Kind regards,
    Pavlina
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. Chen Jun Ying
    Chen Jun Ying avatar
    22 posts
    Member since:
    Apr 2010

    Posted 15 Feb 2012 Link to this post

    Thanks Pavlina.

    Just further our discussion.. Is it possible to make the select/unselect all checkbox work in the header? The solution you provided breaks the unselect all function. I believe GridClientSelectColumn still count those disabled rows.
  4. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 15 Feb 2012 Link to this post

    Hello Chen,

    Can you please specify which version of RadControls you are using?

    Kind regards,
    Pavlina
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  5. Chen Jun Ying
    Chen Jun Ying avatar
    22 posts
    Member since:
    Apr 2010
  6. Fernando
    Fernando avatar
    8 posts
    Member since:
    Apr 2015

    Posted 08 Dec 2016 Link to this post

    It is so much easier to use dataItem.SelectableMode = GridItemSelectableMode.None; in the OnItemCreated event

     

    protected void OnItemCreated(object seneder, GridItemEventArgs e)
    {
        try
        {
            if (e.Item is GridDataItem && e.Item.DataItem != null)
            {
                GridDataItem dataItem = e.Item as GridDataItem;
                DocumentInfo revisao = (DocumentInfo)e.Item.DataItem;
                // Condition to desable the row
                if (revisao.id_revisao.Equals(2)))
                {
                    CheckBox checkBox = (CheckBox)dataItem["ClientSelectColumn"].Controls[0];
                    checkBox.Enabled = false;
                    dataItem.ForeColor = Color.Gray;
                     
                    // here we disable the row
                    dataItem.SelectableMode = GridItemSelectableMode.None;
                }
            }
        }
        catch { }
    }
Back to Top