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; }
("input[id*='CheckBox1']")
ReplyDeleteis that a typo?
sorry my mystake i got it now..
Deleteit's not a typ0
How do you access a control in Edit mode in an .ascx control inside an .aspx page?
ReplyDeleteUsing PivotGrid control for Windows Forms
ReplyDeletevery good,
ReplyDeleteCan you please explain how to set values to bound columns and template columns on client side
Can you please provide your code here or any other forum and provide forum link here?
ReplyDeleteCan you please provide your code here or any other forum and provide forum link here?
ReplyDeleteHi Jayesh,
ReplyDeletePlease provide me the code to get the control inside CommandItemTemplate.
Thanks,
Rajesh
Thank you Jayesh! Very helpful as always!
ReplyDeleteThanks Jayesh. I struggled for more than 3 hours and once i found this article I could able to fix my issue
ReplyDeleteThank You it is very useful to me
ReplyDeleteThank you .we found nothing.
ReplyDeleteMay I help you?
DeleteHow can we set value of a cell
ReplyDeleteHow can we set value of a cell
ReplyDelete@chamarti, Could you please provide your code and explain your requirement?
ReplyDeleteI am using your "Access Control in Edit mode example" having a radtextbox control instead of your checkbox and I want to hide it (or disable it). I do: var textBox1 = $(editItem.get_editFormItem()).find("input[id*='EditCommentsTxtBox']").get(0); and then: textBox1.set_visible(false); But it is not working!!!
ReplyDeleteI get the RadtextBox, the set_visible does not work...
ReplyDeletePlease try with '$telerik.findControl(editItem.get_editFormItem(), "RadTextBox1").set_visible(false)'
ReplyDeleteHi, i tried this but always see this message:
ReplyDelete"Object does not support property or method _get_eventHandlerList"
I just want to show in a message the content of a cell when the user clicks on a command button of the RadGrid.
Best Regards
Could you please share your code with me? my email-id: jayeshgoyani@gmail.com
ReplyDeletein the aspx doc
ReplyDeletein the JS code
function GridCreated(sender, args) {
var grid = sender;
var master = sender.get_masterTableView();
master.selectAllItems(true);
}
function OnClick(index) {
//var master = document.getElementById("ctl00_ContentPlaceHolder1_rgd_Lista_Items").get_masterTableView();
var row = master.get_dataItems()[index]; //accessing row with the Row index
var cell = master.getCellByColumnUniqueName(row, "Codigo"); // Accessing the cell using its UniqueName
alert(cell.innerHTML);
}
The RadGrid contains several rows, the column Codigo contains a string and the goal is obtain a message with that code.
Best Regards
Could you please provide your full code to me, I have already shared my address in above.
ReplyDeletehi Jayesh
ReplyDeletehow to access template column value server side? Because i want to send from grid data to sql table.
Please check below link I have already provided solution for same. http://stackoverflow.com/questions/7989193/findcontrol-gridtemplatecolumn-outside-of-radgrid-events
ReplyDeleteThank you Jayesh! your blog is very helpful as always! 'Access Control in Edit mode' section is work perfectly in my radgrid Edit mode but its not working in the insert mode. so please provide your thoughts.
ReplyDeleteI have updated my code for insert mode.
ReplyDeleteThank's jayesh it's work fine in my code. thanks for your great help.
ReplyDeletesuperb sample code thanks lot.
ReplyDeleteHello Jayesh
ReplyDeleteThank you for article, it was very helpful! :)
How to find form template controls when edit form is popup mode?
ReplyDelete