Customize cell rendering

In this section custom cell rendering is demonstrated using the CellConfigurationExample. All the cells in with the value 'AAA' are rendered with a red background.

Step 1: add custom cell labels to the cells which you want to render differently

    CellOverrideLabelAccumulator cellLabelAccumulator = new CellOverrideLabelAccumulator(gridLayer.getBodyDataProvider());
    cellLabelAccumulator.registerOverride("AAA", 2, CELL_LABEL);

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

Step 2: Register cell attributes in the IConfigRegistry for the labels in step 1

        Style style = new Style();
        // You can set other attributes here
        style.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, GUIHelper.COLOR_RED);

        configRegistry.registerConfigAttribute(
                 CellConfigAttributes.CELL_STYLE,    // attribute to apply
                 style,                              // value of the attribute
                 DisplayMode.NORMAL,    // apply during normal rendering i.e not during selection or edit
                 CELL_LABEL);                   // apply the above for all cells with this label

Comments

Cell color depending on a custom condition

I've only found color selection depending on other column's value, the same column value, the same color.

How can I show in a column, different background colors or better, different icons depending on a custom condition, like a particular combination of states of other hidden objects? Is there any possible configuration to do that?

Regards,
Juan Ferreyra

You can do this by

You can do this by registering each of your different backgrounds, icons, etc with different labels in the ConfigRegistry. Then you can then create a custom ConfigLabelAccumulator to return the appropriate label for the given condition.

The limitation to the above approach is that all possible states must be registered in the ConfigRegistry. This can be problematic if you have a very large set of states. There is a feature request pending to allow the ConfigRegistry to hold dynamic values which would allow this. Stay tuned!