[英]Highlight first row of kendo-grid
I would like to highlight (or select) the first row of a kendo-grid. 我想突出显示(或选择)剑道网格的第一行。 I need to get the first row in a typescript function and add '
k-state-selected
'. 我需要在打字稿函数中获取第一行,并添加“
k-state-selected
”。 The row doesn't have a unique id (except ' ng-reflect-logical-row-index="1"
'). 该行没有唯一的ID(“
ng-reflect-logical-row-index="1"
除外)。 What is the best approach/ implementation to either select (fake a row click, so the row is automatically selected) or highlight the first row. 选择(单击行,因此将自动选择该行)或突出显示第一行的最佳方法/实现是什么?
Kendo has a directive that allows you to add a class to a row based on callback. Kendo的指令允许您基于回调将类添加到行中。
CSS: CSS:
.k-grid tr.selected { background-color: yellow; }
HTML: HTML:
<kendo-grid [data]="gridData" [rowClass]="rowCallback"></kendo-grid>
TS: TS:
public rowCallback(context: RowClassArgs) {
if (context.index == 0) return 'selected';
}
for more information refer to their official documentation . 有关更多信息,请参阅其官方文档 。
If you want to highlight the first row of your kendo Grid
, you can try the following: In my example, the trigger is on page load. 如果要突出显示
kendo Grid
的第一行,可以尝试以下操作:在我的示例中,触发器在页面加载中。 And, it is in jquery. 并且,它在jquery中。 Just convert it to typescript.
只需将其转换为打字稿即可。
$(document).ready(function(){
var grid = $("#gridname").data("kendoGrid");
grid.select("tr:eq(1)");
})
See reference: http://dojo.telerik.com/@Kiril/Ocace 请参阅参考资料: http : //dojo.telerik.com/@Kiril/Ocace
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.