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

Row select using check box checked in Rad grid

3 Answers 443 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Trs
Top achievements
Rank 1
Trs asked on 25 Jan 2013, 06:44 AM
I'm using telerik radgrid view.I have grid view with check boxes.Check boxes are insert to the grid using edit item template. I want to select current row when i'm checking check box.I try to find a solution.but still didn't found solution to my problem. Any inputs will be appreciated and welcome.Thanks

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Jan 2013, 07:58 AM
Hi,

Try the following code.
C#:
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
       CheckBox chk = (CheckBox)sender;
       GridEditFormItem editItem=(GridEditFormItem)chk.NamingContainer;
       GridDataItem ditem = (GridDataItem)editItem.ParentItem;
       ditem.Selected = true;
}

Thanks,
Shinu
0
Trs
Top achievements
Rank 1
answered on 25 Jan 2013, 08:38 AM
Thank you very much shinu. But i want to do this using javascript.(Client side.).Do you have any solutions?
0
Shinu
Top achievements
Rank 2
answered on 28 Jan 2013, 07:07 AM
Hi,

One suggestion is to add a javascript 'OnClick' event in the ItemCreated event on the RadGrid and pass the row index to select the particular row. Please take a look into the following code snippet I tried.

C#:
protected void Radgrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditFormItem && (e.Item.IsInEditMode))
    {
        GridEditFormItem eitem = (GridEditFormItem)e.Item;
        GridDataItem ditem = (GridDataItem)eitem.ParentItem;
        int index = ditem.ItemIndex;
        CheckBox chk = (CheckBox)eitem.FindControl("CheckBox1");
        chk.AutoPostBack = true;
        chk.Attributes.Add("OnClick", "SelectRow('"+index+"')");
    }
}

Javascript:
<script type="text/javascript">
    function SelectRow(index) {
        var grid = $find("<%=Radgrid1.ClientID%>");
        var MasterTable = grid.get_masterTableView();
        var row = MasterTable.get_dataItems()[index];
        row.set_selected(true);
    }
</script>

Thanks,
Shinu.
Tags
General Discussions
Asked by
Trs
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Trs
Top achievements
Rank 1
Share this question
or