RadGrid OnRowClick getting data

2 posts, 1 answers
  1. Robert
    Robert avatar
    5 posts
    Member since:
    Aug 2014

    Posted 22 Sep 2015 Link to this post

    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?

  2. Answer
    Viktor Tachev
    Admin
    Viktor Tachev avatar
    2469 posts

    Posted 24 Sep 2015 Link to this post

    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
Back to Top