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

Problem in finding controls present in edit form template using javascript function

1 Answer 151 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
: Arumuga Vignesh
Top achievements
Rank 1
: Arumuga Vignesh asked on 24 Sep 2014, 01:37 PM
Hi ,

     I have a doubt regarding how to find the controls which are present in form template of radgrid  in javascript function.

 In my web page i have used radgrid and inside that i have used editform template. In form template i have used 5 radnumeric textbox controls. I have to take the value from these textbox and sum it and have to show it in another textbox named as "Total" . The value should be auto calculated. So, for this i am using client side event onBlur. But i am not able to find the controls of the textbox which is present inside the form template in javascript function. Kindly help me to get the values of radnumeric textbox in javascript function.

function test(sender, args) {
var editIndex = $find("<%=txtValue1.ClientID %>"); 
}

here txtValue1 is the ID of radnumeric textbox and i am getting null in editIndex.

Thanks

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 29 Sep 2014, 11:18 AM
Hi Arumuga,

If I understand the setup correctly, all RadNumericTextbox controls are placed in the same container. In this case you could get reference to the parent of the blurred input first and then get reference to the control that you need with the findControl client method. The event where the result will be calculated would look similar to the following:

function onBlur(sender, args) {
    var textBox1;
    var textBox2;
    var textBoxTotal = $telerik.findControl(sender.get_parent().get_element(), "RadNumericTextBox3");
    var total;
 
    // get reference to the other RadNumericTextBox controls here
     
 
    // calculate the total
     
    // set the value for the last RadNumericTextBox
    textBoxTotal.set_value(total);
}

The markup for the EditFormTemplate I used for testing is shown below:

<EditFormSettings EditFormType="Template">
    <FormTemplate>
        <telerik:RadNumericTextBox runat="server" ID="RadNumericTextBox1" ClientEvents-OnBlur="onBlur" />
        <br />
        <telerik:RadNumericTextBox runat="server" ID="RadNumericTextBox2" ClientEvents-OnBlur="onBlur" />
        <br />
        <telerik:RadNumericTextBox runat="server" ID="RadNumericTextBox3" />
    </FormTemplate>
</EditFormSettings>


Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
: Arumuga Vignesh
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or