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

Accessing row data in a command

5 Answers 1409 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 23 Oct 2015, 02:58 PM

I have my grid set up so that it receives some additional information in the json response. I want to use this additional information in the row's commands, but I can't quite figure out how. I've tried putting it in a hidden column, and the data is rendered (but not shown, as expected), but if I try to use #= variable # it literally appends that to the classes, not the value of that row cell.

How can I reference a row value elsewhere in the row? Using a template is fine if necessary.

5 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 27 Oct 2015, 07:38 AM
Hello Steven,

Please check out following example which demonstrates how to get the corresponding data item to which the row is bound on custom command button’s click event:
http://demos.telerik.com/kendo-ui/grid/custom-command
// This dataItem contains all fields from the model object to which the row is bound
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));

Please check it out and let me know if it helps you.

Regards,
Radoslav
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Steven
Top achievements
Rank 1
answered on 02 Nov 2015, 06:36 PM
Thank you, this is very helpful for the commands! Is there a way I can access the information when binding? In addition to my original question, I'd like to use some of the data from the json response in a cell to dynamically display different text.
0
Steven
Top achievements
Rank 1
answered on 02 Nov 2015, 06:41 PM
I should also clarify--I'd like to use the information to change the command button's class when binding, if that's possible.
0
Steven
Top achievements
Rank 1
answered on 03 Nov 2015, 02:22 PM
Sorry for sending a third message. I found using a template for the row and I'm able to access the information that way, but nothing I try will add the commands to the table when I use a table to format the data (instead of an empty div like I was doing previously). How can I insert custom commands when using a table?
0
Kostadin
Telerik team
answered on 04 Nov 2015, 09:34 AM
Hi Steven,

You can use a dataBound event to traverse all rows and change/add a class name. The same way you will be able to change the text of the command column. Please check the following dojo.

Regards,
Kostadin
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Steven
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Steven
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or