This is a migrated thread and some comments may be shown as answers.

GridCheckBoxColumn - client side highlight row when checkbox is clicked

1 Answer 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
aljjxw
Top achievements
Rank 1
aljjxw asked on 07 Jul 2015, 08:01 AM

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");
}

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 10 Jul 2015, 06:40 AM
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
Tags
Grid
Asked by
aljjxw
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or