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

grid client event

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Seban
Top achievements
Rank 1
Seban asked on 24 Sep 2012, 08:36 AM
  Sir,
                I have a grid ,contains 5 ckeckbox template columns , any check box is clicked 6th check box  value is changed in clientside.
Pls help me . we are telerick customer.
          By Seban.
 

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 24 Sep 2012, 12:45 PM
Hello,

<telerik:RadGrid ID="RadGrid3" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid3_NeedDataSource"
        OnItemDataBound="RadGrid3_ItemDataBound">
        <MasterTableView>
            <Columns>
                <telerik:GridTemplateColumn>
                    <ItemTemplate>
                        <asp:CheckBox ID="Chk1" runat="server" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn>
                    <ItemTemplate>
                        <asp:CheckBox ID="Chk2" runat="server" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn HeaderText="ID" DataField="ID" UniqueName="ID">
                </telerik:GridBoundColumn>
 
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
protected void RadGrid3_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
 
    dynamic data = new[] {
            new { ID = 1, Name ="Name1"},
            new { ID = 2, Name = "Name2"},
            new { ID = 3, Name = "Name3"}
        };
    RadGrid3.DataSource = data;
 
 
}
protected void RadGrid3_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = e.Item as GridDataItem;
        CheckBox Chk1 = item.FindControl("Chk1") as CheckBox;
        CheckBox Chk2 = item.FindControl("Chk2") as CheckBox;
 
        // default first check box will be checked
        Chk1.Checked = true;
 
        Chk1.Attributes.Add("onclick", "checkUncheckManage(this,'" + Chk2.ClientID+ "')");
        Chk2.Attributes.Add("onclick", "checkUncheckManage(this,'" + Chk1.ClientID + "')");
    }
}
function checkUncheckManage(chkA, chkB) {
            var _chkB = document.getElementById(chkB);
            _chkB.checked = !chkA.checked;
        }

OR
Also checked below link for reference
Access Another control which was in same level or in row
How to access the control from itemtemplate in Radgrid on client side


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Seban
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or