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

Get elements in the EditItemTemplate through javascript

3 Answers 193 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Parth
Top achievements
Rank 1
Parth asked on 30 Aug 2010, 04:57 PM

Hello,

I am using Telerik grid. I have some GridTemplateColumn. Inside those columns there are EditItemTemplate column. Inside that I have <asp:checkbox>. I have intotal 5 checkboxes defined the same way. The condition I want is that out of 5 checkboxes if I click on one of the checkbox it will uncheck other 4 checkboxes. I got the object of the gridtemplatecolumn but I dont know what to do further. Any help will be appreciated

Code:

 

 

 

 

 

<telerik:GridTemplateColumn HeaderText="Activity - Fit/Exam" SortExpression="q9a_bit" UniqueName="q9a_bit" EditFormColumnIndex="0" DataField="q9a_bit" Display="false">
   <ItemTemplate>
   </ItemTemplate>
   <EditItemTemplate>
       <asp:CheckBox ID="id1" runat="server" Checked="<%#Bind('q9a_bit') %>"/>
   </EditItemTemplate>
</telerik:GridTemplateColumn>
                          
<telerik:GridTemplateColumn HeaderText="Activity - Refraction" SortExpression="q9b_bit" UniqueName="q9b_bit" EditFormColumnIndex="0" DataField="q9b_bit" Display="false">
    <ItemTemplate>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:CheckBox ID="id2" runat="server" Checked="<%#Bind('q9b_bit') %>"/>
    </EditItemTemplate>
</telerik:GridTemplateColumn>
                          
<telerik:GridTemplateColumn HeaderText="Activity - Rx Change" SortExpression="q9c_bit" UniqueName="q9c_bit" EditFormColumnIndex="0" DataField="q9c_bit" Display="false">
   <ItemTemplate>
   </ItemTemplate>
   <EditItemTemplate>
       <asp:CheckBox ID="id3" runat="server" Checked="<%#Bind('q9c_bit') %>"/>
   </EditItemTemplate>
</telerik:GridTemplateColumn>
                          
<telerik:GridTemplateColumn HeaderText="Activity - Purchase Only" SortExpression="q9d_bit" UniqueName="q9d_bit" EditFormColumnIndex="0" DataField="q9d_bit" Display="false">
    <ItemTemplate>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:CheckBox ID="id4" runat="server" Checked="<%#Bind('q9d_bit') %>"/>
    </EditItemTemplate>
</telerik:GridTemplateColumn>
                          
<telerik:GridTemplateColumn HeaderText="Activity - Purchase Only" SortExpression="q9e_bit" UniqueName="q9e_bit" EditFormColumnIndex="0" DataField="q9e_bit" Display="false">
    <ItemTemplate>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:CheckBox ID="id5" runat="server" onclick="return check_uncheck ();" Checked="<%#Bind('q9e_bit') %>"/>
    </EditItemTemplate>
</telerik:GridTemplateColumn>

 

Javascript:

 

<script type="text/javascript">
      
function check_uncheck() {
  var grid = $find("<%=RadGrid1.ClientID%>");
  var tableView = grid.get_masterTableView();
  alert(tableView.getCellByColumnUniqueName(tableView.get_dataItems()[0],"q9a_bit"));
}
  
</script>

Regards,
Parth

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 31 Aug 2010, 07:39 AM
Hello,


Use the findElement() method to get the DOM element of html or rendered server control (CheckBox here) inside the grid row. For getting the corresponding row, pass the index to 'onclick" event from code behind (in ItemCreated event of grid), then by using the index access the row client object.


-Shinu.
0
Parth
Top achievements
Rank 1
answered on 31 Aug 2010, 07:58 PM
Shinu,

Everytime I try to access the element, it allows me to get the innerHTML value but not the checked property value. The data I am getting is of ItemTemplate and not of EditItemTemplate. I need the value of the checkbox from the EditItemTemplate. If you can send me an example I would really appreciate your help.

Thanks.
Parth
0
Accepted
Shinu
Top achievements
Rank 2
answered on 01 Sep 2010, 01:11 PM
Hello Parth,


I noticed that in a code library it is shows how to access server control in a grid template from client side. Please refer the following link.
Accessing server controls in a grid template on the client



-Shinu.
Tags
Grid
Asked by
Parth
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Parth
Top achievements
Rank 1
Share this question
or