Get rowID from column button click in ClientTemplate

2 posts, 0 answers
  1. Dave
    Dave avatar
    29 posts
    Member since:
    Aug 2010

    Posted 11 Aug 2015 Link to this post

    Hi,

    I've been searching for an answer for this for the last 3 hours and can't even find an explanation if this isn't possible. I have a Grid where I've replaced the row Guid's with .Model(model => { model.Id(p => p.OrderID);}). In one of my columns, I've added a button in a Client template, this column needs to be bound to a value. When the user clicks the button I've made in the Client Template, I need both this value and the OrderID that I've replaced the Guid with, to get the row and thus the row's data. Of course I can't set the Id of the Client Template html control because you only allow to input a raw string for that. At the same time, you don't allow a single column to be bound to multiple fields. I've seen .Bound(p=> new {X = p.y, Y= p.z}) but that won't work.

    Any help on this? This seems to be a common feature that is needed. Only being able to bind to one thing, and not being able to get the selected row through events.Change() (because I need the event to fire on the specific cell button click, not just clicking anywhere on the row)  seems like a major failure on the part of the Grid control in general.

  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2303 posts

    Posted 12 Aug 2015 Link to this post

    Hello Dave,

    It is not completely clear for us why removing the data-uid attribute of the Grid rows is required. Could you elaborate further? Regarding the specific case, you could use jQuery's closest() method to get the current row from the button's click handler.
    E.g.

    function onClick(){
      var row = $(this).closest("tr");
    }

    Regards,
    Dimiter Madjarov
    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