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

access controls inside edititemtemplate from javascript

1 Answer 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Loyal User
Top achievements
Rank 1
Loyal User asked on 17 Sep 2013, 07:34 AM
hello all, 
I have 2 textbox as shown in code below : 


<telerik:GridTemplateColumn UniqueName="guarantyAmount" HeaderText="<%$Resources:Strings,amount  %>">
                    <ItemTemplate>
                        <asp:Label Text='<%# Eval("WARRANTY_AMOUNT")%>' runat="server" id="warrantyAmountText">
                            </asp:Label>
                    </ItemTemplate>
                   <EditItemTemplate>
                
                       <telerik:RadNumericTextBox runat="server" id="warrantyAmount" ClientEvents-OnValueChanging="warrantyAmount_ValueChanging"></telerik:RadNumericTextBox>
                        </EditItemTemplate>
                   </telerik:GridTemplateColumn>
                 
                  <%--<telerik:GridBoundColumn DataField="REAL_VALUE" HeaderText='<%$Resources:Strings,realValue %>' UniqueName="guarantyRealValue"/>--%>
              <telerik:GridTemplateColumn UniqueName="guarantyRealValue" HeaderText="<%$Resources:Strings,realValue  %>">
                    <ItemTemplate>
                        <asp:Label Text='<%# Eval("REAL_VALUE")%>' runat="server" id="realValueText">
                            </asp:Label>
                    </ItemTemplate>
                   <EditItemTemplate>
                
                       <telerik:RadNumericTextBox runat="server" id="realValue"></telerik:RadNumericTextBox>
                        </EditItemTemplate>
                   </telerik:GridTemplateColumn>


what i want is to create  " warrantyAmount_ValueChanging " js function that read input value from "warrantyAmount " textbox and put them in "realValue" ..

how can i achieve that ??


1 Answer, 1 is accepted

Sort by
0
Accepted
Angel Petrov
Telerik team
answered on 20 Sep 2013, 06:16 AM
Hi Elsy,

Since the controls are rendered in the same NamingContainer you can try the following:
function warrantyAmount_ValueChanging(sender,args) {
          var value = args.get_newValue();
          var realValue = $find(sender.get_id().replace("warrantyAmount", "realValue"));
          realValue.set_value(value);
      }

The code logic above obtains a reference to the realValue RadNumericTextBox by modifying the last part of the warrantyAmount numeric in order to get the realValue id. Later using $find() we reference the client-object of the control and set it's value.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Loyal User
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or