Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Adding a summary header for columns and rows
Adding a summary header for columns and rows [message #1807718] Thu, 06 June 2019 15:49 Go to next message
Michael Haywood is currently offline Michael HaywoodFriend
Messages: 4
Registered: July 2018
Junior Member
I would like to add a single header for a group of columns and rows.

I've tried using `ColumnGroupHeaderLayer` but the text is in the centre of the column. Instead I would like it to always have the text drawn in the centre of the visible cell and always remain in the same position as I scroll.

I've looked through a lot of documentation but I'm struggling to find anything on how I could do this.

I've attached an example of what I'm aiming for.

Is it possible to achieve this with NatTable?
Re: Adding a summary header for columns and rows [message #1807725 is a reply to message #1807718] Thu, 06 June 2019 18:32 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
You could either try to use the recently introduced performance column and row group header layer like in this example
https://github.com/eclipse/nebula.widgets.nattable/blob/master/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_500_Layers/_511_Grouping/_5115_HugeColumnGroupingExample.java

Or you implement something similar to the GroupByHeaderLayer.

So it is possible but probably not simple out of the box.
Re: Adding a summary header for columns and rows [message #1807749 is a reply to message #1807725] Fri, 07 June 2019 10:57 Go to previous messageGo to next message
Michael Haywood is currently offline Michael HaywoodFriend
Messages: 4
Registered: July 2018
Junior Member
I've managed to get a column group to work correctly. The only issue is that by making columns wider I can get the group header text to move off of the screen. The tables can be quite large and I always want the group header displayed. Instead I need it to stay in the centre of what is currently visible.

I noticed there is a method call "columnGroupHeaderLayer.setShowAlwaysGroupNames(true);" in the example you linked. This sounds like it does what I want but the method doesn't exist.

I'm using version 1.5.0.
Re: Adding a summary header for columns and rows [message #1807750 is a reply to message #1807749] Fri, 07 June 2019 11:20 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
The example I have linked is from the current 1.6 SNAPSHOT codebase and the performance column and row grouping was recently added. So it is only available with that code base. In 1.5 there is no way to achieve this via the existing ColumnGroupHeaderLayer.

With 1.5 I think the only way is something similar to the GroupByHeaderLayer which means an extended CompositeLayer with a simple painter that only takes the available space into account by providing only a single cell and a custom painter similar to the GroupByHeaderPainter.
Re: Adding a summary header for columns and rows [message #1807758 is a reply to message #1807750] Fri, 07 June 2019 14:51 Go to previous messageGo to next message
Michael Haywood is currently offline Michael HaywoodFriend
Messages: 4
Registered: July 2018
Junior Member
I've managed to get a composite layer to work correctly for the columns header but I can't get it to work for the row headers.

	/**
	 * 
	 * Column Header composite
	 * 
	 */

	final CompositeLayer compositeColumnHeaderLayer = new CompositeLayer(1, 2);

	final GroupByHeaderLayer groupByColumnHeaderLayer = new GroupByHeaderLayer(new GroupByModel(), columnLayer,
		columnData);

	compositeColumnHeaderLayer.setChildLayer(GroupByHeaderLayer.GROUP_BY_REGION, groupByColumnHeaderLayer, 0, 0);
	compositeColumnHeaderLayer.setChildLayer("Grid", columnLayer, 0, 1);

	/**
	 * 
	 * 
	 * Row Header composite
	 * 
	 */

	final CompositeLayer compositeRowHeaderLayer = new CompositeLayer(2, 1);

	final GroupByHeaderLayer groupByRowHeaderLayer = new GroupByHeaderLayer(new GroupByModel(), rowLayer, rowData);

	compositeRowHeaderLayer.setChildLayer(GroupByHeaderLayer.GROUP_BY_REGION, groupByRowHeaderLayer, 0, 0);
	compositeRowHeaderLayer.setChildLayer("Grid", rowLayer, 1, 0);

	/**
	 * 
	 * 
	 * Grid Creation
	 * 
	 */

	final CornerLayer cornerLayer = new CornerLayer(cornerDataLayer, compositeRowHeaderLayer,
		compositeColumnHeaderLayer);

	final GridLayer gridlayer = new GridLayer(bodyLayer, compositeColumnHeaderLayer, compositeRowHeaderLayer,
		cornerLayer);



This successfully adds a row above the column headers but the row headers end up displaying incorrectly.

It looks as though I'm creating the row header composite layer the same as the column header composite. Do you know what might be causing it?
Re: Adding a summary header for columns and rows [message #1807759 is a reply to message #1807758] Fri, 07 June 2019 15:10 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2814
Registered: July 2012
Senior Member
You can not simply use the GroupByHeaderLayer as row header. The dimensions are not matching. That's why I said you need to create something similar. Have a look at the implementation details.
Previous Topic:Nattable create cell value
Next Topic:Labels not working with sorting
Goto Forum:
  


Current Time: Wed Jun 16 12:14:48 GMT 2021

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

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

Back to the top