通过按顺序而运行回调或判别式,适用已通过的样式组,并且忽视其他。它类似于JavaScript等的switch语句。 如果在相关位置存在回调,表达式就会被忽视。 而且,如果没有在相关位置设置样式组,就会使用上述设置。
当添加为DataColumn.dynamicStyles等的设置对象时,如果在设置对象中,存在"expressions"或"callbacks"属性,就会被创建为该对象。
var columns = [{
name: 'colQty',
fieldName: 'quantity',
dynamicStyles:[{
expressions: [
"row % 5 == 0",
"row % 3 == 0"
],
styles: [{
shapeSize: size1,
numberFormat: fmt1
}, {
shapeSize: size2,
numberFormat: fmt2
}]
}]
}, {
callbacks: [
function (cell) {
return cell.rowIndex() % 5 == 0;
},
function (cell) {
return cell.rowIndex() % 3 == 0;
}
],
styles: [{
shapeSize: size1,
numberFormat: fmt1
}, {
shapeSize: size2,
numberFormat: fmt2
}]
},
...
];
grid.setColumns(columns);