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

Set row style based on non-displayed column

1 Answer 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 06 Jun 2012, 06:27 PM
Suppose I have 
<button id='btn' class='k-button' data-nodeid='111'>XYZ</button>
<div id='grid1'></div>

and data
var rows = [
  { "one": "1", "two": "21", "three": "31", "nodeid":' ' }
,   { "one": "2", "two": "22", "three": "32", "nodeid":' ' }
,   { "one": "3", "two": "23", "three": "33", "nodeid":'123' }
,   { "one": "4", "two": "24", "three": "34", "nodeid":' ' }   
    ];
 
var btnNodeid = $('#btn').data('nodeid');
 
$('#grid1').kendoGrid({
    dataSource: rows
)}

What I would like is to set a row to display in italics when the row that has a nodeid value different than that of the button.  I do not want to show the nodeid in the grid.

I've tried templating the row with no success

var window.btnid = $("#btn").data('nodeid');
...
kendoGrid({
...
rowTemplate: '<tr #if (nodeid != ' ' && nodeid != window.btnid) { class=italic }#><td>${one}</td><td>${two}</td> .... ';





1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 07 Jun 2012, 09:10 AM
Hello Richard,

There are several errors in the template. For example -

- window.btnid is undefined and even if btnid is the button's ID,  the expression will not return what you expect
- italic should be in quotes
- class="italic" should be outside the exacutable portion of the template

Please consult the Expressions demo and the part "Using JavaScript code inside the template definition". If you need further assistance, please submit a support ticket.

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