Get Client Data key on Client
Get Template Column Control
Access Column Text
Access Column's property here
Access Control in Edit mode
Access Control in insert mode
ASPX
ASPX.CS
<telerik:radcodeblock id="RadCodeBlock1" runat="server"> <script type="text/javascript"> function AccessOnclient() { var grid = $find("<%= RadGrid1.ClientID %>"); if (grid) { var MasterTable = grid.get_masterTableView(); var Rows = MasterTable.get_dataItems(); for (var i = 0; i < Rows.length; i++) { var row = Rows[i]; var ClientDataKey_ID = row.getDataKeyValue("ID"); } } return false; } </script> </telerik:radcodeblock>
<telerik:radcodeblock id="RadCodeBlock1" runat="server"> <script type="text/javascript"> function AccessOnclient() { var grid = $find("<%= RadGrid1.ClientID %>"); if (grid) { var MasterTable = grid.get_masterTableView(); var Rows = MasterTable.get_dataItems(); for (var i = 0; i < Rows.length; i++) { var row = Rows[i]; // Method1 var lblName_1 = $(row.get_element()).find("span[id*='lblName']").get(0); // Method2 var lblName_2 = $telerik.findControl(row.get_element(), "lblName"); // Method3 var lblName_3 = row.findControl("lblName"); } } return false; } </script> </telerik:radcodeblock>
<telerik:radcodeblock id="RadCodeBlock1" runat="server"> <script type="text/javascript"> function AccessOnclient() { var grid = $find("<%= RadGrid1.ClientID %>"); if (grid) { var MasterTable = grid.get_masterTableView(); var Rows = MasterTable.get_dataItems(); for (var i = 0; i < Rows.length; i++) { var row = Rows[i]; // Method1 var getCellText_1 = row.get_element().cells[0].innerHTML; // Method2 var getCellText_2 = row.get_cell("ID").innerHTML; // Method3 var getCellText_2 = row.get_cell("Name").getElementsByTagName("span")[0].innerHTML; //this code also work for Checkboxcolunm, hyperlinkcolumn...etc } } return false; } </script> </telerik:radcodeblock>
<telerik:radcodeblock id="RadCodeBlock1" runat="server"> <script type="text/javascript"> function AccessOnclient() { var grid = $find("<%= RadGrid1.ClientID %>"); if (grid) { var MasterTable = grid.get_masterTableView(); var Columns = MasterTable.get_columns(); for (var i = 0; i < Columns.length; i++) { var column = Columns[0]; var columnUniqueName = column.get_uniqueName(); var columnDataField = column.get_dataField(); var columnfilterFunction = column.get_filterFunction(); } } return false; } </script> </telerik:radcodeblock>
<telerik:radcodeblock id="RadCodeBlock1" runat="server"> <script type="text/javascript"> function AccessOnclient() { var grid = $find("<%= RadGrid1.ClientID %>"); if (grid) { var EditItems = grid.get_editItems(); for (var i = 0; i < EditItems.length; i++) { var editItem = EditItems[0]; var checkbox1 = $(editItem.get_editFormItem()).find("input[id*='CheckBox1']").get(0) } } return false; } </script> </telerik:radcodeblock>
<telerik:radcodeblock id="RadCodeBlock1" runat="server"> <script type="text/javascript"> function AccessOnclient() { var grid = $find("<%= RadGrid1.ClientID %>"); if (grid) { var MasterTable = grid.get_masterTableView(); var insertRow = MasterTable.get_insertItem(); var checkbox1 = $(insertRow).find("input[id*='CheckBox1']").get(0); //You can access other controls from below container //$(insertRow) } return false; } </script> </telerik:radcodeblock>
<telerik:radscriptmanager id="RadScriptManager1" runat="server"> </telerik:radscriptmanager> <telerik:radajaxmanager id="RadAjaxManager1" runat="server"> </telerik:radajaxmanager> <telerik:radajaxloadingpanel id="RadAjaxLoadingPanel1" runat="server"> </telerik:radajaxloadingpanel> <asp:button id="Button1" onclientclick="return AccessOnclient();" runat="server" text="Access On Client"></asp:button> <telerik:radgrid allowfilteringbycolumn="true" autogeneratecolumns="false" id="RadGrid1" onneeddatasource="RadGrid1_NeedDataSource" runat="server"> <mastertableview clientdatakeynames="ID" commanditemdisplay="Top"> <columns> <telerik:gridboundcolumn datafield="ID" headertext="ID" uniquename="ID"> </telerik:gridboundcolumn> <telerik:gridtemplatecolumn headertext="Name" uniquename="Name"> <itemtemplate> <asp:label id="lblName" runat="server" text="<%# Eval("Name") %>"></asp:label> </itemtemplate> <edititemtemplate> <asp:checkbox id="CheckBox1" runat="server"> </asp:checkbox></edititemtemplate> </telerik:gridtemplatecolumn> <telerik:grideditcommandcolumn uniquename="EditColumn"> </telerik:grideditcommandcolumn> </columns> </mastertableview> </telerik:radgrid>
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { dynamic data = new[] { new { ID = 1, Name ="Name_1"}, new { ID = 2, Name = "Name_2"}, new { ID = 3, Name = "Name_3"}, new { ID = 4, Name = "Name_4"}, new { ID = 5, Name = "Name_5"} }; RadGrid1.DataSource = data; }