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

RadGrid OnRowClick getting data

1 Answer 309 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 22 Sep 2015, 03:45 PM

UI for ASP.NET AJAX version: 2015.1.225

I'm trying to grab information from the radgrid when the user selects a row.  The Javascript function fires as expected, but I can't seem to get the right syntax to grab the cell information.

    <script type="text/javascript">
        function launchDetails(sender, eventArgs) {

        }
    </script>

If I use 'sender.MasterTableView.getColumnByUniqueName("caseName");' I get the column information as expected.
If I use 'parseInt(eventArgs.get_itemIndexHierarchical());' I get the selected row index as expected.

If I use 'sender.MasterTableView.getCellByColumnUniqueName(parseInt(eventArgs.get_itemIndexHierarchical()),"caseName");' I get the following error:
'Uncaught TypeError: a.get_element is not a function(…)' at 'Telerik.Web.UI.GridTableView.getCellByColumnUniqueName'

I've also tried this line of code without the 'parseInt', but obtain the same results.  How can I grab the "caseName" at the designated clicked row?

1 Answer, 1 is accepted

Sort by
0
Accepted
Viktor Tachev
Telerik team
answered on 24 Sep 2015, 11:17 AM
Hello Robert,

In order to retrieve the name from the selected row client-side you can use the approach illustrated in the following code snippet.


function rowSelected(sender, args) {
    var grid = sender;
    var masterTableView = grid.get_masterTableView();
    var selectedRow = args.get_item();
    var name = selectedRow.getDataKeyValue("Name");
 
    alert(name);
}

Note that in order for the getDataKeyValue() method to work you need to add the corresponding data field to the ClientDataKeyNames collection of the GridTableView.


Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or