get whole object on click grid row

2 posts, 0 answers
  1. MV
    MV avatar
    1 posts
    Member since:
    Dec 2015

    Posted 10 Jun 2016 Link to this post

    I am using kendo Grid of kendo of ASP.NET MVC 2016.1.412.

    My code where I want to get selected is:

     

    column.Bound(e => e.Username).Title("Username").Groupable(true).ClientTemplate("<a style='cursor:pointer' onclick=EditProductDataObject(Username)>#=Username#</a>");

     

    Here instead of username I want to pass whole row object so I can read and use further the coming data.

  2. Eyup
    Admin
    Eyup avatar
    3296 posts

    Posted 14 Jun 2016 Link to this post

    Hi,

    You can achieve this requirement using the following approach:
    columns.Bound(p => p.ProductName).Title("ProductName").Groupable(true).ClientTemplate("<a style='cursor:pointer' onclick='EditProductDataObject(this);'>#=ProductName#</a>");
    JavaScript:
    function EditProductDataObject(linkEl) {
        var row = $(linkEl).closest("tr");
        var dataItem = $("#grid").data("kendoGrid").dataItem(row);
        alert(dataItem.ProductName);
    }

    That should do the trick. Please give it a try and let me know if it works for you.

    Regards,
    Eyup
    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