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

Get control id with in grid

3 Answers 142 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nabil
Top achievements
Rank 1
Nabil asked on 03 Mar 2009, 10:58 AM
I am working on grid having three columns. First two columns has text boxes and third has label to show sum of first two columns. Kindly give me client side script to get id of these controls within grid.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Mar 2009, 11:26 AM
Hello Nabil,

You can check out the following code library submission which demonstrates on how to access controls placed in templates inside the grid on the client:
Accessing server controls in a grid template on the client

Thanks
Princy.
0
Nabil
Top achievements
Rank 1
answered on 03 Mar 2009, 12:12 PM
Thanks for the prompt reply. This is nice approach to get clientid. But what if I want to get the clientid of the control in the next column? Means i want to show the sum of column 1 and 2 in third column. Calculation will be made on onblur or onchange event of first two columns. That is when user write text in textbox and focus out of the control then calculation will be made by adding value of first column and second column.
0
Daniel
Telerik team
answered on 03 Mar 2009, 01:07 PM
Hello Nabil,

Test the following:
<script type="text/javascript" language="javascript"
    function changeValue(sender, args) 
    { 
        var row = sender.get_element().parentNode.parentNode.parentNode; 
        var inputs = row.getElementsByTagName("input"); 
        for (var i = 0; i < inputs.length; i++) 
        { 
            if (inputs[i].id.match("rtb2$")) 
                $find(inputs[i].id).set_value("10"); 
        } 
    } 
</script> 

<telerik:GridTemplateColumn UniqueName="Col1"
    <EditItemTemplate> 
        <telerik:RadTextBox ID="rtb1" ClientEvents-OnFocus="changeValue" runat="server" /> 
    </EditItemTemplate> 
</telerik:GridTemplateColumn> 
<telerik:GridTemplateColumn UniqueName="Col2"
    <EditItemTemplate> 
        <telerik:RadTextBox ID="rtb2" runat="server" /> 
    </EditItemTemplate> 
</telerik:GridTemplateColumn> 

Hope this helps.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Nabil
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Nabil
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or