Question : Get the values of a cell in a selected row of a RadGrid on client Side

Hey there everyone, I'm hoping there is a simple fix for this, but I would accept a complicated one after messing around with it for the last day and a half!

I am putting together a module that will drop into a DotNetNuke portal and I'm populating a Telerik RadGrid with data. I have followed every tutorial and example I can find, but the result keeps coming back with "object Object", "null", or "undefined".

I need to:
1) get the value of the "BookingID'" column for each row that is selected
2) pass the value into a url string that opens up in a RadWindow.

I'm trying to do all of this using javascript, but if you know a better way, I'm down for anything at this point.
Here are some of the tutorials and examples I have followed to no avail:

http://stackoverflow.com/questions/761633/select-a-radgrid-row-client-side-inside-radwindows
http://www.telerik.com/help/aspnet/grid/grdgettingcellvaluesforselectedrowsclientside.html
http://www.telerik.com/community/forums/aspnet-ajax/grid/extracting-cell-values-from-radgrid.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/client/selecting/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/client/keys/defaultcs.aspx

Here is my current JavaScript and a stripped down radGrid:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
///Javascript///

    function gup(name) {
        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
        var regexS = "[\\?&]" + name + "=([^&]*)";
        var regex = new RegExp(regexS);
        var results = regex.exec(window.location.href);
        if (results == null) return "";
        else return results[1];
    }
        function ShowEditForm() {
            var tab = gup('tabid')
            var mid = gup('mid').replace(/#/, '')
            var masterTableView = $find("perDiemBookingsRadGrid").get_masterTableView();
            var id = masterTableView.get_selectedItems()[0].getDataKeyValue('BookingID');

            window.radopen("/Default.aspx?tabid=" + tab + "&ctl=multiEdit&mid=" + mid + "&SkinSrc=[G]Skins/Blue-NCPP/Plain&BIDs=" + id, "RadWindow3");
        }


///Grid////
<telerik:RadGrid ID="perDiemBookingsRadGrid" runat="server" AllowPaging="True" AllowSorting="True"
                    DataSourceID="perDiemBookingsSqlDataSource" GridLines="None" ShowGroupPanel="True"
                    AllowAutomaticDeletes="True" AllowMultiRowSelection="True" Width="800px" AllowAutomaticUpdates="True"
                    AutoGenerateColumns="False" >
                    <MasterTableView DataSourceID="perDiemBookingsSqlDataSource" DataKeyNames="BookingID"
                        CommandItemDisplay="Top">
                        <CommandItemTemplate>
                            <div style="padding: 5px 5px;">
                                <a href="#" onclick="return ShowEditForm();" visible='<%# perDiemBookingsRadGrid.EditIndexes.Count = 0 %>'>
                                    <img style="border: 0px; vertical-align: middle;" alt="" src="/images/Edit.gif" />
                                    Show Edit Form</a> &nbsp;&nbsp;
                            </div>
                        </CommandItemTemplate>
                        <Columns>
                            <telerik:GridClientSelectColumn Reorderable="False" Resizable="False" ShowSortIcon="False"
                                UniqueName="column">
                            </telerik:GridClientSelectColumn>
                            <telerik:GridBoundColumn DataField="BookingID" UniqueName="BookingID" DataType="System.Int32"
                                HeaderText="BookingID" ReadOnly="True" SortExpression="BookingID" Visible="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn DataField="CustomerName" HeaderText="Customer" UniqueName="Customer"
                                EditFormColumnIndex="2" GroupByExpression="GROUP BY CustomerName" SortExpression="CustomerName">
                                <EditItemTemplate>
			</Columns>
                        <EditFormSettings ColumnNumber="3">
                            <EditColumn UniqueName="EditCommandColumn1">
                            </EditColumn>
                        </EditFormSettings>
                    </MasterTableView>
                    <ClientSettings AllowDragToGroup="True">
                        <Selecting AllowRowSelect="True"/>
                    </ClientSettings>
</telerik:RadGrid>

Answer : Get the values of a cell in a selected row of a RadGrid on client Side

Check this :

(you do just an alert at then end, uncomment the last lines if the alert look fine of course)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
function openRadWindow() {
		var id = "";
		var c_content = document.getElementsByClassName("c_content");
		var table = c_content[0].getElementsByTagName("table")[0];
		var rows = table.getElementsByTagName("tr");
		for(var i=0;i<rows.length;i++) {
			var checkbox = rows[i].cells(0).childNodes[0];
			var BookingID = rows[i].cells(1).childNodes[1].childNodes[0].textContent;
			if(checkbox.checked) {
				if(id.length>0) {
					id += "," + BookingID; 
				}
				else {
					id += BookingID; 
				}
			}
		}
		alert('window.radopen("/Default.aspx?tabid=" + tab + "&ctl=multiEdit&mid=" + mid + "&BIDs="' + id + ', "RadWindow3");');
		//if(id.length>0) {
			//window.radopen("/Default.aspx?tabid=" + tab + "&ctl=multiEdit&mid=" + mid + "&BIDs=" + id, "RadWindow3");
		//}
	}
Random Solutions  
 
programming4us programming4us