GridCheckBoxColumn - client side highlight row when checkbox is clicked

2 posts, 0 answers
  1. aljjxw
    aljjxw avatar
    1 posts
    Member since:
    Jul 2015

    Posted 07 Jul 2015 Link to this post

    Ho can I highlight the row when the checkbox is selected?

    I added the following, but it doen't work after a filter or sort because the rowIdx is correct only when all rows are displayed. 

    Any idea

    CODE BEHIND: 
    ----------------------

      int rowIdx = 0;
      protected void grdLegalEntities_ItemCreated(object sender, GridItemEventArgs e)
            {
                  if (e.Item is GridDataItem)
                {
                    GridDataItem item = (GridDataItem)e.Item;
                    CheckBox chk = (CheckBox)item["clmyesno"].Controls[0];
                    chk.Enabled = true;
                    chk.Attributes.Add("onclick", "SelectCurrentRow(" + rowIdx + ");");
                    rowIdx++;
                }
            }

    JAVASCRIPT:
    ---------------------
    function SelectCurrentRow(rowIdx) 
    {
        var grid = $find('<%=grdLegalEntities.ClientID %>');               
        grid.get_masterTableView().get_dataItems()[rowIdx].set_selected("true");
    }

     

  2. Eyup
    Admin
    Eyup avatar
    3801 posts

    Posted 10 Jul 2015 Link to this post

    Hi,

    You can make avail of the built-in GridClientSelectColumn to achieve this requirement:
    http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/selecting/row-selection/defaultcs.aspx

    Hope this helps.

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top