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

selected row value in clientside

1 Answer 11 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dawson
Top achievements
Rank 1
Dawson asked on 15 Nov 2013, 01:31 PM
Hi,
I have a master and child grid. I want to access the selected row value in clientside on a button click. Some one help me with this. 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 15 Nov 2013, 01:46 PM
Hi Dawson,

Please try the following code snippet.

ASPX:
<ClientSettings Selecting-AllowRowSelect="true"/>
. . . . .
<asp:Button ID="Button1" runat="server" Text="Get Value" OnClientClick="Click()" />

JS:
<script type="text/javascript">
 function Click()
 {
    var grid = $find("<%=RadGrid1.ClientID %>");
    var MasterTable = grid.get_masterTableView();
    //Access Parent table items
    var selectedrow = MasterTable.get_selectedItems();
    var length = MasterTable.get_selectedItems().length;
    for (var i = 0; i < length; i++) {
        var id = MasterTable.get_selectedItems()[i].get_id();
        var cell = MasterTable.getCellByColumnUniqueName(selectedrow[i], "ParentColumnName");
        alert(cell.innerHTML);
    }
  // Access Detail table Items
    var dataItems = MasterTable.get_dataItems();
    for (var i = 0; i < dataItems.length; i++) {
        if (dataItems[i].get_nestedViews().length > 0) {
            var cell = dataItems[i].get_nestedViews()[0].get_selectedItems()[0].get_cell("ChildColumnName");
            alert(cell.innerHTML);
        }
    }
}
   
</script>

Thanks,
Princy
Tags
Grid
Asked by
Dawson
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or