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

Loop through Grid and find Textbox

3 Answers 216 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ajay
Top achievements
Rank 1
Ajay asked on 02 Dec 2011, 01:36 PM
Hi

I am trying to write some code which will loop through a RadGrid and find any RadNumericTextBox in the dit template.

The code below works for the first row in the grid but no any others. Any ideas?
Thanks in advance

function ConvertToDegreeMinutesSeconds_Grid(Longitude, Latitude) {
var rgrdRouteWayPoints = $find("<%=rgrdRouteWayPoints.ClientID %>");
 if (rgrdRouteWayPoints) {
                        var MasterTable = rgrdRouteWayPoints.get_masterTableView();
                        var Rows = MasterTable.get_dataItems();
                        for (var i = 0; i < Rows.length; i++) {
                            var row = Rows[i];
         
                            var rtxtLongDegree_Grid = row.findControl("rtxtLongDegree_Grid");
                                                        
                            var rtxtLongMin_Grid = row.findControl("rtxtLongMin_Grid");
                            var rtxtLongSec_Grid = row.findControl("rtxtLongSec_Grid");

                            var rtxtLatDegree_Grid = row.findControl("rtxtLatDegree_Grid");
                            var rtxtLatMin_Grid = row.findControl("rtxtLatMin_Grid");
                            var rtxtLatSec_Grid = row.findControl("rtxtLatSec_Grid");

                            rtxtLongDegree_Grid.set_value(Longitude_Deg);
                            rtxtLongMin_Grid.set_value(Longitude_Min);
                            rtxtLongSec_Grid.set_value(Longitude_Sec);

                            rtxtLatDegree_Grid.set_value(Latitude_Deg);
                            rtxtLatMin_Grid.set_value(Latitude_Min);
                            rtxtLatSec_Grid.set_value(Latitude_Sec);
 
                        }
                    }

                }

                function rcbPortList_Grid_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");

                    ConvertToDegreeMinutesSeconds_Grid(Longitude, Latitude);

                }

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Dec 2011, 01:50 PM
Hello Ajay,

Check the following code library which explains how to access server controls from client side.
Accessing server controls in a grid template on the client

-Shinu.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 02 Dec 2011, 02:03 PM
Hello Ajay,

You want to access textbox on client side In EditMode.

Let me know its corrct or not?

If yes then please also tell me which method you used for edit the row.(like : EditForms/Inplace/PopUp).

Thanks
Jayesh Goyani
0
Ajay
Top achievements
Rank 1
answered on 02 Dec 2011, 02:13 PM
Yes... I want to access the box on client side and I am using InPlace edit mode.

The code works only for the first row and then I get error...

On another note I have some code from yourself below:

This works but I don't know how to change it so I can use RadNumericTextbx instead of Combo like in your example

   <script type="text/javascript">
        function onSelectedIndexChanged(sender, args) {
            var RadComboBox2 = $("input[id*='" + sender.get_id() + "']").parent().parent().parent().find("div[id*='RadComboBox2']").attr("id")
            var RadComboBox3 = $("input[id*='" + sender.get_id() + "']").parent().parent().parent().find("div[id*='RadComboBox3']").attr("id")
            if (args.get_item().get_value() == "Yes") {
                $find(RadComboBox2).enable();
                $find(RadComboBox3).enable();
            }
            else {
                $find(RadComboBox2).disable();
                $find(RadComboBox3).disable();
            }
        }
    </script>
Tags
Grid
Asked by
Ajay
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jayesh Goyani
Top achievements
Rank 2
Ajay
Top achievements
Rank 1
Share this question
or