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

Get rowID from column button click in ClientTemplate

1 Answer 399 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 12 Aug 2015, 01:19 AM

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.

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 12 Aug 2015, 04:28 PM

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
Tags
Grid
Asked by
Dave
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or