我想设置单行样式并避免为我行的每个单元格定义格式化程序。新的 Dojo dgrid 是否有等效的 onStyleRow 事件?小部件?
谢谢。
最佳答案
我最终得到了两个截然不同的解决方案:
在使用 dgrid 的 Controller 中,基于 https://github.com/SitePen/dgrid/issues/236#issuecomment-11508012 中给出的解决方法
aspect.after(myDgrid, "renderRow", function(row, args) { var data = args[0]; if (data.unread) { domClass.add(row, "unread"); } return row; });
在我自己的 dgrid 定义中,但没有“use strict”——否则这将不起作用,你会得到这个错误:
TypeError: 'caller', 'callee', and 'arguments'不能在严格模式函数或调用它们的参数对象上访问属性
:return declare("com.my.myDgrid", [ Grid, ... ], { columns : [ { ... } ], renderRow : function() { var row = this.inherited(arguments); var data = arguments[0]; if (data.unread) { domClass.add(row, "unread"); } return row; } });
样式是通过这个简单的 CSS 规则完成的:
#myDgridId .unread td {
font-weight: bold;
}
关于javascript - 道场 dgrid : how style a single row?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20498977/