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

Populate RadNumeric Box in RadGrid via RadComboBox Selection

4 Answers 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ajay
Top achievements
Rank 1
Ajay asked on 01 Dec 2011, 11:47 AM
Hi

I have a RadComboBox (EnableLoadOnDemand is True) and 3 numeric boxes in Edit Template in a RadGrid.

What I am trying to do is when a user selects a option in the RadComboBox then it populates the Textboxes via its attributes.

I have the following javascript which I have used to do this previously but not in a Grid

                function rcb_Changed(sender, args) {
                    //copy port long/lat to input boxes
                    var item = args.get_item();
                    var Longitude = item.get_attributes().getAttribute("Longitude");
                    var Latitude = item.get_attributes().getAttribute("Latitude");

                     var rtxtLongDegree = $find("<%=rtxtLongDegree.ClientID %>");
                    rtxtLongDegree.set_value(Longitude_Deg);

                }
<telerik:RadComboBox ID="rcbPortList" runat="server" AllowCustomText="false" DropDownWidth="590px"
   EmptyMessage=" - Select a port - " EnableLoadOnDemand="True" Height="150px" HighlightTemplatedItems="true"
   MarkFirstMatch="True" Width="170px" OnClientSelectedIndexChanged="rcb_Changed"
   ShowMoreResultsBox="True" EnableVirtualScrolling="True">

I have tried chaging "<%=rtxtLongDegree.ClientID %>" to the name of the Textbox in the Grid Edit Template but I get an error saying it cannot find the control.

How do I do this is so when I change the ComboxBox in the Grid it populates the textboxes,,... Using Javascript.

Thanks in advance

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Dec 2011, 12:09 PM
Hello,

Take a look into the following code library which explained the way of accessing server side control via javascript.
Accessing server controls in a grid template on the client

Thanks,
Princy.
0
Ajay
Top achievements
Rank 1
answered on 01 Dec 2011, 04:22 PM
Tried using this example

I get js error "rtxtLongDegree_Grid" is undefined

My js is

var rtxtLongDegree = GetGridServerElement(rtxtLongDegree_Grid, "input");
rtxtLongDegree.set_value(Longitude_Deg);

                function GetGridServerElement(serverID, tagName) {
                    if (!tagName)
                        tagName = "*"; //* means all elements

                    var grid = document.getElementById("<%=rgrdRouteWayPoints.ClientID %>");
                    var elements = grid.getElementsByTagName(tagName);
                    for (var i = 0; i < elements.length; i++) {
                        var element = elements[i];
                        if (element.id.indexOf(serverID) >= 0)
                            return element;
                    }
                }

rtxtLongDegree_Grid is the name of my RadNumeric Text box in the RadGrid

Any ideas???

0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 01 Dec 2011, 05:06 PM
0
Ajay
Top achievements
Rank 1
answered on 02 Dec 2011, 11:17 AM
Thanks Jayesh worked a treat
Tags
Grid
Asked by
Ajay
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ajay
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or