Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Multi Level Column Grouping
Multi Level Column Grouping [message #1175025] Thu, 07 November 2013 13:23 Go to next message
Rajesh Arumugam is currently offline Rajesh ArumugamFriend
Messages: 24
Registered: October 2013
Junior Member
Hi All,

I have created a nattable successfully with one level grouping..

As shown in the image, 1st level grouping is working fine.. Now i need to add second level Column grouping.. Here is the code..
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import net.sourceforge.nattable.data.IColumnPropertyAccessor;
import net.sourceforge.nattable.data.IDataProvider;
import net.sourceforge.nattable.data.ListDataProvider;
import net.sourceforge.nattable.data.ReflectiveColumnPropertyAccessor;
import net.sourceforge.nattable.grid.data.DefaultColumnHeaderDataProvider;
import net.sourceforge.nattable.grid.data.DefaultCornerDataProvider;
import net.sourceforge.nattable.grid.data.DefaultRowHeaderDataProvider;
import net.sourceforge.nattable.grid.layer.ColumnHeaderLayer;
import net.sourceforge.nattable.grid.layer.CornerLayer;
import net.sourceforge.nattable.grid.layer.DefaultColumnHeaderDataLayer;
import net.sourceforge.nattable.grid.layer.DefaultRowHeaderDataLayer;
import net.sourceforge.nattable.grid.layer.GridLayer;
import net.sourceforge.nattable.grid.layer.RowHeaderLayer;
import net.sourceforge.nattable.group.ColumnGroupHeaderLayer;
import net.sourceforge.nattable.group.ColumnGroupModel;
import net.sourceforge.nattable.layer.DataLayer;
import net.sourceforge.nattable.selection.SelectionLayer;
import net.sourceforge.nattable.util.IClientAreaProvider;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.GlazedLists;

public class FVNatTableBuilderGridLayer extends GridLayer
{

    private final DataLayer bodyDataLayer;
    private final DataLayer columnHeaderDataLayer;
    private FVNatTableBuilderBodyLayerStack bodyLayer;
    private ListDataProvider<SignalInfo> bodyDataProvider;
    private final ColumnGroupModel sndColumnGroupModel = new ColumnGroupModel();

    // private EventList valuesToShow = GlazedLists.eventList(new ArrayList());
    EventList<SignalInfo> eventList = GlazedLists.eventList(new ArrayList());

    private IColumnPropertyAccessor<SignalInfo> columnPropertyAccessor;

    public FVNatTableBuilderGridLayer()
    {
        super(true);
        eventList.addAll(getSignalInfoList());
        String[] propertyNames = SignalInfoList.getPropertyNames();
        Map<String, String> propertyToLabelMap = SignalInfoList.getPropertyToLabelMap();

        columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<SignalInfo>(propertyNames);

        bodyDataProvider = new ListDataProvider<SignalInfo>(eventList, columnPropertyAccessor);

        bodyDataLayer = new DataLayer(bodyDataProvider);
        bodyLayer = new FVNatTableBuilderBodyLayerStack(bodyDataLayer);

        // Column header
        IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames,
                propertyToLabelMap);
        columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
        ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer,
                bodyLayer, bodyLayer.getSelectionLayer());

        ColumnGroupHeaderLayer columGrpHeaderLayer = new ColumnGroupHeaderLayer(columnHeaderLayer,
                bodyLayer.getSelectionLayer(), new ColumnGroupModel());

        columGrpHeaderLayer.addColumnsIndexesToGroup("Functional Class", 9);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Maximum In-Rush Current (A)", 10, 11);
        columGrpHeaderLayer.addColumnsIndexesToGroup(" Maximum Stall Circuit Current (A)", 12, 13);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Nominal Steady State Operating Current (A) at Voltage (V)", 14, 15);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Minimum Steady State Operating Current (A) at Voltage (V)", 16, 17);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Maximum Steady State Operating Current (A) at Voltage (V)", 18, 19);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Output Type (Relay / FET/ BJT/ Other)", 20);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Overload Protection", 21);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Signal Type", 22);

        // 2nd set of fields - Final Attributes.
        columGrpHeaderLayer.addColumnsIndexesToGroup("Functional Voltage (V)", 23, 24);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Lifetime cycles", 25);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Performance Voltage (V)", 26, 27);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Maximum module output internal voltage drop @ 10.5 V", 28);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Maximum Steady State Operating Current at 10.5V", 29);
        columGrpHeaderLayer.addColumnsIndexesToGroup("HSD SC Maximum Detection Current (A)", 30);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Minimum Operating Duration or Activation Time (msec)", 31);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Maximum Operating Duration or Activation Time (sec)", 32);

        columGrpHeaderLayer.addColumnsIndexesToGroup("PWM Frequency (Hz) ", 33, 34);
        columGrpHeaderLayer.addColumnsIndexesToGroup("PWM Minimum Rise Time Output  ", 35);
        columGrpHeaderLayer.addColumnsIndexesToGroup("PWM Minimum Fall Time Output", 36);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Twisting (T) / Shield (S) Requirement", 37);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Wake Up", 38);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Powertrain CDS Version", 39);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Comments"
                + "\n(List additional information such as:" + "\n SDS non-compliances,"
                + "\n how you terminate unused pins etc . . ."
                + "\n Highlight any SDS non-compliances in RED) ", 40);

        columGrpHeaderLayer.setRowHeight(230);

        /*ColumnGroupGroupHeaderLayer sndGroup = new ColumnGroupGroupHeaderLayer(columGrpHeaderLayer,
                bodyLayer.getSelectionLayer(), sndColumnGroupModel);

        sndGroup.addColumnsIndexesToGroup("Initial", 11, 12, 13, 14);*/

        // Row header
        DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(
                bodyDataProvider);
        DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(
                rowHeaderDataProvider);
        RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, bodyLayer, bodyLayer
                .getSelectionLayer());

        // Corner
        DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(
                columnHeaderDataProvider, rowHeaderDataProvider);
        DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
        CornerLayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer,
                columGrpHeaderLayer);

        // Grid
        setBodyLayer(bodyLayer);
        setColumnHeaderLayer(columGrpHeaderLayer);
        setRowHeaderLayer(rowHeaderLayer);
        setCornerLayer(cornerLayer);

    }

}

But if i try to add 2nd level grouping with ColumnGroupGroupHeaderLayer, then the table is broken, its repeating column name 2 times.
the result becomes like this..

Initial
--------------------------
FunctionalVolt|Max Current
---------------------------
FunctionalVolt|Max Current

Where as i need result like,

Initial
------------------------------
FunctionalVolt|Max Current
------------------------------
A\B\C|Min | Max |

ie Min, Max belongs to Max Current Column Group
A\B\C belongs to FunctionalVolt Column Group
And Both Functional Class, Max Current belongs to Initial column group.



And here is the code for second level grouping..
public class FVNatTableBuilderGridLayer extends GridLayer
{

    private final DataLayer bodyDataLayer;
    private final DataLayer columnHeaderDataLayer;
    private FVNatTableBuilderBodyLayerStack bodyLayer;
    private ListDataProvider<SignalInfo> bodyDataProvider;
    private final ColumnGroupModel sndColumnGroupModel = new ColumnGroupModel();

    // private EventList valuesToShow = GlazedLists.eventList(new ArrayList());
    EventList<SignalInfo> eventList = GlazedLists.eventList(new ArrayList());

    private IColumnPropertyAccessor<SignalInfo> columnPropertyAccessor;

    public FVNatTableBuilderGridLayer()
    {
        super(true);
        eventList.addAll(getSignalInfoList());
        String[] propertyNames = SignalInfoList.getPropertyNames();
        Map<String, String> propertyToLabelMap = SignalInfoList.getPropertyToLabelMap();

        columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<SignalInfo>(propertyNames);

        bodyDataProvider = new ListDataProvider<SignalInfo>(eventList, columnPropertyAccessor);

        bodyDataLayer = new DataLayer(bodyDataProvider);
        bodyLayer = new FVNatTableBuilderBodyLayerStack(bodyDataLayer);

        // Column header
        IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames,
                propertyToLabelMap);
        columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
        ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer,
                bodyLayer, bodyLayer.getSelectionLayer());

        ColumnGroupHeaderLayer columGrpHeaderLayer = new ColumnGroupHeaderLayer(columnHeaderLayer,
                bodyLayer.getSelectionLayer(), new ColumnGroupModel());

        columGrpHeaderLayer.addColumnsIndexesToGroup("Functional Class", 9);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Maximum In-Rush Current (A)", 10, 11);
        columGrpHeaderLayer.addColumnsIndexesToGroup(" Maximum Stall Circuit Current (A)", 12, 13);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Nominal Steady State Operating Current (A) at Voltage (V)", 14, 15);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Minimum Steady State Operating Current (A) at Voltage (V)", 16, 17);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Maximum Steady State Operating Current (A) at Voltage (V)", 18, 19);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Output Type (Relay / FET/ BJT/ Other)", 20);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Overload Protection", 21);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Signal Type", 22);

        // 2nd set of fields - Final Attributes.
        columGrpHeaderLayer.addColumnsIndexesToGroup("Functional Voltage (V)", 23, 24);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Lifetime cycles", 25);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Performance Voltage (V)", 26, 27);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Maximum module output internal voltage drop @ 10.5 V", 28);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Maximum Steady State Operating Current at 10.5V", 29);
        columGrpHeaderLayer.addColumnsIndexesToGroup("HSD SC Maximum Detection Current (A)", 30);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Minimum Operating Duration or Activation Time (msec)", 31);
        columGrpHeaderLayer.addColumnsIndexesToGroup(
                "Maximum Operating Duration or Activation Time (sec)", 32);

        columGrpHeaderLayer.addColumnsIndexesToGroup("PWM Frequency (Hz) ", 33, 34);
        columGrpHeaderLayer.addColumnsIndexesToGroup("PWM Minimum Rise Time Output  ", 35);
        columGrpHeaderLayer.addColumnsIndexesToGroup("PWM Minimum Fall Time Output", 36);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Twisting (T) / Shield (S) Requirement", 37);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Wake Up", 38);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Powertrain CDS Version", 39);
        columGrpHeaderLayer.addColumnsIndexesToGroup("Comments"
                + "\n(List additional information such as:" + "\n SDS non-compliances,"
                + "\n how you terminate unused pins etc . . ."
                + "\n Highlight any SDS non-compliances in RED) ", 40);

        columGrpHeaderLayer.setRowHeight(230);

ColumnGroupGroupHeaderLayer sndGroup = new ColumnGroupGroupHeaderLayer(columGrpHeaderLayer,
                bodyLayer.getSelectionLayer(), sndColumnGroupModel);

        sndGroup.addColumnsIndexesToGroup("Initial", 9, 10, 11);

        // Row header
        DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(
                bodyDataProvider);
        DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(
                rowHeaderDataProvider);
        RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, bodyLayer, bodyLayer
                .getSelectionLayer());

        // Corner
        DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(
                columnHeaderDataProvider, rowHeaderDataProvider);
        DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
        CornerLayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, sndGroup);

        // Grid
        setBodyLayer(bodyLayer);
        setColumnHeaderLayer(sndGroup);
        setRowHeaderLayer(rowHeaderLayer);
        setCornerLayer(cornerLayer);

    }
}

can anyone let me what mistake i am doing and help me to fix this..

Also, I want to add different configuration for different layer. ie. Want to align column Grouping names,in vertical manner and their group columns in horizonal manner.. in the sense, Column Group 'Functional Class' should be in vertical order where as its group column 'A\B\C' should be in horizontal order. When i am trying to add Vertical painter to Column header layer, its aligning all columns in vertical manner, except Column grouping columns.

[Updated on: Thu, 07 November 2013 13:25]

Report message to a moderator

Re: Multi Level Column Grouping [message #1175051 is a reply to message #1175025] Thu, 07 November 2013 13:49 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2752
Registered: July 2012
Senior Member
Not sure, maybe simply a wrong reference anywhere. Did you double check with the example code in NatTable examples?

Regarding the vertical painting, if you want to change the rendering of the column grouping, you should register the painter for the column group header and not the column header.

But you will notice that in that case both column grouping headers will render differently. The reason you are not able to use a different painter in the second level group is that in both cases the same label COLUMN_GROUP_HEADER is applied. Your only option in that case right now is to override the ColumnGroupGroupHeaderLayer.getConfigLabelsByPosition() and return another label to which you are able to register a different painter.

Multi level column grouping is something that should be reworked completely, but currently there is no time and no committer available to do that. Any working contributions are welcome! Smile
Re: Multi Level Column Grouping [message #1175108 is a reply to message #1175051] Thu, 07 November 2013 14:27 Go to previous messageGo to next message
Rajesh Arumugam is currently offline Rajesh ArumugamFriend
Messages: 24
Registered: October 2013
Junior Member
Hi Drik,

Thanks for your quick response. I tried with example code, but with my custom data provider. With that also, i am facing the same issue. Also, i noticed that, If i select the column and try to rename the column(added DefaultMenuConfiguration to the column header, In the rename dialog, its showing original name as 'Max' which is correct, but in the table its showing 'Max Current' which is column group name not column name.. Sad
Re: Multi Level Column Grouping [message #1175125 is a reply to message #1175108] Thu, 07 November 2013 14:41 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2752
Registered: July 2012
Senior Member
Which version are you using?

Did you try to use different indexes?
Re: Multi Level Column Grouping [message #1175223 is a reply to message #1175125] Thu, 07 November 2013 15:56 Go to previous messageGo to next message
Rajesh Arumugam is currently offline Rajesh ArumugamFriend
Messages: 24
Registered: October 2013
Junior Member
Hi Drik,

The version is 2.3.1 Yes, the indexes are different.are you suggesting not to go with ColumnGroupGroupHeaderLayer?need to work on ColumnGroupHeaderLayer itself to support multi-level column grouping?
Re: Multi Level Column Grouping [message #1175343 is a reply to message #1175223] Thu, 07 November 2013 17:48 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2752
Registered: July 2012
Senior Member
You are still using the sourceforge version?

Well in that case there might be bugs or whatever. That version is more than one year old and there were numerous bugfixes since then. I suggest to update to the latest Nebula version 1.0.1 or a development snapshot. Otherwise I'm not able to help you.
Re: Multi Level Column Grouping [message #1176825 is a reply to message #1175343] Fri, 08 November 2013 15:27 Go to previous messageGo to next message
Rajesh Arumugam is currently offline Rajesh ArumugamFriend
Messages: 24
Registered: October 2013
Junior Member
Dear Drik,
With new plug-ins, 2nd level column grouping is working fine. Thanks for your help.. Smile
Re: Multi Level Column Grouping [message #1186147 is a reply to message #1176825] Thu, 14 November 2013 14:10 Go to previous messageGo to next message
Rajesh Arumugam is currently offline Rajesh ArumugamFriend
Messages: 24
Registered: October 2013
Junior Member
Hi Drik,

2nd level column grouping is working fine with latest jar. Now i am facing issue on vertical alignment for column header. As you suggested i am returning my own LabelStack to which i registered custom painter. But the code is not working.

@Override
    public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
    {
        int colIdx = getColumnIndexByPosition(columnPosition);
        int rowIndex = getRowIndexByPosition(rowPosition);

        if ((colIdx == 9 || colIdx == 11 || colIdx == 12 || colIdx == 13 || colIdx == 14 || colIdx == 15)
                && rowIndex == 0)
        {
            LabelStack labelStack = new LabelStack();
            if (getConfigLabelAccumulator() != null)
            {
                getConfigLabelAccumulator().accumulateConfigLabels(labelStack, columnPosition,
                        rowPosition);
            }
            labelStack.addLabelOnTop(HEADER_LABEL1);
            return labelStack;

        }

        // TODO Auto-generated method stub
        return super.getConfigLabelsByPosition(columnPosition, rowPosition);
    }


This is the style i am trying to apply to the specific cell.
 
protected void addHorizontalStyle(IConfigRegistry configRegistry, NatTable natTable)
    {

        Style cellStyle = new Style();
        Color summaryRowFgColor = GUIHelper.COLOR_BLACK;
        Color summaryRowBgColor = GUIHelper.COLOR_BLUE;
        Font summaryRowFont = GUIHelper.getFont(new FontData("Verdana", 8, SWT.BOLD));
        BorderStyle summaryRowBorderStyle = new BorderStyle(0, GUIHelper.COLOR_BLACK,
                LineStyleEnum.DOTTED);
        cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT,
                HorizontalAlignmentEnum.CENTER);
        cellStyle.setAttributeValue(CellStyleAttributes.FONT, summaryRowFont);
        cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, summaryRowBgColor);
        cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, summaryRowFgColor);
        cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, summaryRowBorderStyle);
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle,
                DisplayMode.NORMAL, FVNatTableColumnGrpHeaderLayer1.HEADER_LABEL1);
    }


Its not working. Do i miss anything?

[Updated on: Thu, 14 November 2013 14:10]

Report message to a moderator

Re: Multi Level Column Grouping [message #1186156 is a reply to message #1186147] Thu, 14 November 2013 14:15 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2752
Registered: July 2012
Senior Member
Not sure if I understand your request correctly and you just mixed up horizontal and vertical in your explanation. But we solved the vertical stuff by adding an additional label to the column header like this in another project:

columnHeaderDataLayer.setConfigLabelAccumulator(new IConfigLabelAccumulator() {
	@Override
	public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
		configLabels.addLabel(FVNatTableColumnGrpHeaderLayer1.HEADER_LABEL1);
	}
});
Re: Multi Level Column Grouping [message #1200754 is a reply to message #1186156] Thu, 21 November 2013 11:48 Go to previous messageGo to next message
Rajesh Arumugam is currently offline Rajesh ArumugamFriend
Messages: 24
Registered: October 2013
Junior Member
Hi Drik,

I am still facing the same issue after overwriting custom label. Here is my table..

Initial
------|------|-----|-----|-----|
Col-1 | Col-2|Col-3|Grp-1|Grp-2|
------|------|-----|-----|-----|
AB|BC|DE|EF|

What i want to do is :
Arrange and paint 1st column header - Initial (horizontal alignment is working be default)
Arrange the center column header - Col1 --Grp-2 in vertical manner(Its working fine)
Arrange the last column header- AB|BC|DE.. in horizontal manner

Here is my approach :
1. Created a columnheader layer that contains columns - Col-1 Col-2 Col3 AB BC DE EF
2. Created a column group header layer to group AB,BC to Grp-1 and DE,EF to Grp-2
3. Created a column group group header layer to group Grp-1, Grp-2 to 'Initial'

And i applied VerticalTextPainter to column header layer.. This makes my center and last column header in vertical manner.. But i want only my center column header in vertical manner and last column header in horizontal manner.

I understood i need to override the label and register my own label.. but how can i override 2nd level column grouping cells.

I am trying to override column group group header layer label like this... but its not working..

 IConfigLabelAccumulator cellLabelAccumulator = new IConfigLabelAccumulator() {
            public void accumulateConfigLabels(LabelStack configLabels, int columnPosition,
                    int rowPosition)
            {
                int columnIndex = sndGroup.getColumnIndexByPosition(columnPosition);
                int rowIndex = sndGroup.getRowIndexByPosition(rowPosition);

                if ((columnIndex == 9 || columnIndex == 10 || columnIndex == 11
                        || columnIndex == 12 || columnIndex == 13 || columnIndex == 14
                        || columnIndex == 15 || columnIndex == 16 || columnIndex == 17
                        || columnIndex == 18 || columnIndex == 19 || columnIndex == 20
                        || columnIndex == 21 || columnIndex == 22)
                        && rowIndex == 0)
                {

                    configLabels.addLabel(FOO_LABEL);
                }

            }
        };
        sndGroup.setConfigLabelAccumulator(cellLabelAccumulator);



If i modify the same code, for bodyLayer(replaced all sndGroup with bodyLayer, then my custom painter is working fine for this custom label)

-regards,
Rajesh

Re: Multi Level Column Grouping [message #1200815 is a reply to message #1200754] Thu, 21 November 2013 12:27 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2752
Registered: July 2012
Senior Member
It's because the ColumnGroupHeaderLayer and the ColumnGroupGroupHeaderLayer apply the same region label.
And because both are returning a new LabelStack instead of using the one from the super class, so the accumulators are not called.

That's why I hate the current multiple column group implementation. But it would be too much effort to refactor it in NatTable 1.x. Unless anybody pays for it, we will consider those issues in the new architecture.

Till then you need to override the methods in the layer.

ColumnGroupHeaderLayer columnGroupHeaderLayer = new ColumnGroupHeaderLayer(columnHeaderLayer, bodyLayer.getSelectionLayer(), columnGroupModel)
{
	@Override
	public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
		LabelStack result = super.getConfigLabelsByPosition(columnPosition, rowPosition);
		int columnIndex = getColumnIndexByPosition(columnPosition);
		int rowIndex = getRowIndexByPosition(rowPosition);
		if (rowIndex == 0 && this.isColumnInGroup(columnIndex)) {
			result.addLabel("MyLabel");
		}
		return result;
	}
};


Re: Multi Level Column Grouping [message #1203295 is a reply to message #1200815] Fri, 22 November 2013 15:31 Go to previous messageGo to next message
Rajesh Arumugam is currently offline Rajesh ArumugamFriend
Messages: 24
Registered: October 2013
Junior Member
Hi Drik,

Thank you very much. Its working fine. I am able to make things work by overriding label. My last question... Is it possible to add Sorting and filtering support, if we have multiple column grouping?
Re: Multi Level Column Grouping [message #1203321 is a reply to message #1203295] Fri, 22 November 2013 15:49 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2752
Registered: July 2012
Senior Member
It should, but never tried before
Previous Topic:Left border is not drawn
Next Topic:Pop up menu in Editable cells.
Goto Forum:
  


Current Time: Mon Dec 16 12:32:42 GMT 2019

Powered by FUDForum. Page generated in 0.02590 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top