views:

7537

answers:

5

Hello! I have a RadGrid inside of RadWindow... I need to select a Radgrid row in clientside... How can I do that?

I´m trying to get the radgrid like that: var masterTable = $find("<%=radgridID.ClientID%>").get_masterTableView();

but always getting null...

Any help?

+1  A: 

Is your Javascript inside a RadCodeBlock:

<telerik:HeadTag runat="server" ID="Headtag2"></telerik:HeadTag>
    <!-- custom head section -->
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
         <!--
            function RowSelected(sender, args)
            {
                document.getElementById("<%= Label1.ClientID %>").innerHTML =
                 "<b>CustomerID: </b>" + args.getDataKeyValue("CustomerID") +
                 "<br />" +
                 "<b>CompanyName: </b>" + args.getDataKeyValue("CompanyName");
            }

            function GetFirstDataItemKeyValues()
            {
             var firstDataItem = $find("<%= RadGrid1.MasterTableView.ClientID %>").get_dataItems()[0];
             var keyValues =
                    'CustomerID: "' + firstDataItem.getDataKeyValue("CustomerID") + '"' +
                 ' \r\n' +
                 'CompanyName: "' + firstDataItem.getDataKeyValue("CompanyName") + '"';
             alert(keyValues);
            }
            -->
        </script>
        </telerik:RadCodeBlock>
    <!-- end of custom head section -->
</head>

Here is the link to the sample. I made the same error of just including the javascript function but without the code block tab.

David Robbins
+2  A: 

I got it... Code :

var oManager = GetRadWindowManager();  
var oWnd = oManager.GetWindowByName("RadWindow1");     
var grid = oWnd.GetContentFrame().contentWindow.$find('RadGrid1') //Get reference to RadGrid 
var masterTable = grid.get_masterTableView();  
masterTable.selectItem(3);  //Select 4th row
Paul
A: 

hi, i bind a employee table to my RadGrid so my columns for RadGrid are 'emp_name', 'emp_dept', 'emp_city'.

now, what i want is when i select a perticular row of RadGrid i need to access all the values of that perticular row in a javascript function.

i tried to find these values in 'args' but i havn't found the luck.

Please help.

joy
A: 

yes my code is in 'RadCodeBlock'

i have assigned the OnSelect function for grid from code behind -> employeeGrid.ClientSettings.ClientEvents.OnRowSelecting = "GetOneUser";

and my function is in javascript

function GetOneUser(sender, args) {
alert(args.getDataKeyValue('emp_name')); }

but this is not working ata all. I am geting 'null' as an alert

joy
A: 

var grid = $find("<%=grdList.ClientID %>"); var firstDataItem = grid.get_masterTableView().get_dataItems()[grid._selectedIndexes[0]]; var keyValues = firstDataItem.getDataKeyValue("id_estadoreq"); alert(keyValues);

PRUEBEN ESTOOO!!!

SALUDOS..........

Michael Rivera