0

我正在尝试根据存储在模型对象中的 RGB 值更改 NatTable 中行的颜色。我找到了有关如何在我的 NatTable 中设置自定义样式的信息,但这些似乎都使用预定义的标签,而不是基于动态值的标签。

//add custom cell label to cells that contain value AAA in column 2
CellOverrideLabelAccumulator cellLabelAccumulator 
= new CellOverrideLabelAccumulator(gridLayer.getBodyDataProvider());
cellLabelAccumulator.registerOverride("AAA", 2, CELL_LABEL);

// Register label accumulator with the data layer
bodyDataLayer.setConfigLabelAccumulator(cellLabelAccumulator);

CELL_LABEL 是一个链接到预建标签的字符串。

4

1 回答 1

0

NatTable 中的样式概念基于您已经找到的机制。您将标签附加到单元格(通常用于某些特殊条件)并为该标签注册样式。这样 NatTable 就实现了样式和内容的分离。

由于您的方法是将样式信息和数据保存在一个模型对象中,因此您需要找到一种方法将其放入 NatTable。

基本上,您需要注册一个标签以某种方式表示您的模型对象。然后为包含模型对象的背景颜色信息的标签注册一个样式。

于 2016-02-02T22:11:09.927 回答