Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Merged columns in a tree grid
Merged columns in a tree grid [message #1401454] Tue, 15 July 2014 16:38 Go to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Hi,

I am using Nattable in my application to show a tree grid with three levels. It works perfectly as I give a list of row objects with parent and child rows. Now I want to add headers in the tree grid and certain known rows. So my idea is to add a row for the header rows in between with data for only one column and merge/combine other columns on that row. Is there a way to do this in the Nattable tree grid?
Re: Merged columns in a tree grid [message #1401511 is a reply to message #1401454] Tue, 15 July 2014 18:28 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Sorry, I don't understand what you are trying to achieve.

Do you want to add a row for each tree root node? Or another row in the column header?

Either way, to achieve this you typically need to implement a additional layer that adds the row to the composition. This way the column header grouping or the filter row is implemented.

For the "combination" of cells you need spanning like the SpanningDataLayer, at least something similar.
Re: Merged columns in a tree grid [message #1401576 is a reply to message #1401511] Tue, 15 July 2014 21:05 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Sorry I didnt explain clearly. No, I do not need to add a row for each tree root node. Lets say I have a tree grid with 10 root nodes (and each one could have different number of children). I need to add a row say after 7th root node. But the row i have to add does not need any child row but should like a single column spanning the entire row. (To give a header row kind of feel). Is this something possible to do?

If so, Can you give me an example of how to add a SpanningDataLayer for a tree grid?
Re: Merged columns in a tree grid [message #1401579 is a reply to message #1401511] Tue, 15 July 2014 21:05 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Sorry I didnt explain clearly. No, I do not need to add a row for each tree root node. Lets say I have a tree grid with 10 root nodes (and each one could have different number of children). I need to add a row say after 7th root node. But the row i have to add does not need any child row but should like a single column spanning the entire row. (To give a header row kind of feel). Is this something possible to do?

If so, Can you give me an example of how to add a SpanningDataLayer for a tree grid?
Re: Merged columns in a tree grid [message #1401580 is a reply to message #1401511] Tue, 15 July 2014 21:06 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Sorry I didnt explain clearly. No, I do not need to add a row for each tree root node. Lets say I have a tree grid with 10 root nodes (and each one could have different number of children). I need to add a row say after 7th root node. But the row i have to add does not need any child row but should like a single column spanning the entire row. (To give a header row kind of feel). Is this something possible to do?

If so, Can you give me an example of how to add a SpanningDataLayer for a tree grid?
Re: Merged columns in a tree grid [message #1401581 is a reply to message #1401511] Tue, 15 July 2014 21:07 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Sorry I didnt explain clearly. No, I do not need to add a row for each tree root node. Lets say I have a tree grid with 10 root nodes (and each one could have different number of children). I need to add a row say after 7th root node. But the row i have to add does not need any child row but should like a single column spanning the entire row. (To give a header row kind of feel). Is this something possible to do?

If so, Can you give me an example of how to add a SpanningDataLayer for a tree grid?
Re: Merged columns in a tree grid [message #1401743 is a reply to message #1401511] Wed, 16 July 2014 03:17 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Sorry I didnt explain clearly. No, I do not want to add a row for each root node or another row in the column header. Lets say I have a tree grid with 10 rows and 8 columns with different number of child rows under each root node. After 7 rows, I want to add a row that has only one column, where all the 8 columns are combined or spanned in a single column. Is it possible to achieve this? If so, can you provide an example for adding a row with spanned cells?
Re: Merged columns in a tree grid [message #1401771 is a reply to message #1401743] Wed, 16 July 2014 04:15 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
You want to add a row in the middle of your tree? Currently I don't have an idea how to solve that. As that would mean to introduce a mechanism that will modify positions only for the last 3 rows while the first 7 rows need to be untouched in the special layer. Implementing an example for such a case would cost me quite a while as this is not a trivial task.

If you simply want to span a row of data that is already in your data collection, then use the SpanningDataLayer or a custom one that is similar to it. There are several examples on spanning in the examples.
Re: Merged columns in a tree grid [message #1402042 is a reply to message #1401771] Wed, 16 July 2014 12:29 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Thanks, I will try the SpanningDataLayer. I dont necessarily have to insert that row. I could add that in the tree grid list of rows. So In my example I will have 11 rows and the 8th row would be a single column spanning the entire 8 columns.
Re: Merged columns in a tree grid [message #1402043 is a reply to message #1401771] Wed, 16 July 2014 12:29 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Thanks, I will try the SpanningDataLayer. I dont necessarily have to insert that row. I could add that in the tree grid list of rows. So In my example I will have 11 rows and the 8th row would be a single column spanning the entire 8 columns.
Re: Merged columns in a tree grid [message #1402263 is a reply to message #1402043] Wed, 16 July 2014 19:28 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Hi,

I see the SpanningDataLayer example, but I do not understand how i can set it up on the tree grid. For example in a normal grid it is setup like this

ViewportLayer layer = new ViewportLayer(
				new SelectionLayer(
						new SpanningDataLayer(new DummySpanningBodyDataProvider(100, 100))));



In case of tree grid, this is how the layers are set up in my case

   ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer( m_dataLayer );
        ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer( columnReorderLayer );
        SelectionLayer selectionLayer = new SelectionLayer( columnHideShowLayer );

        // tree layer
        TreeLayer treeLayer = new TreeLayer( selectionLayer, new GlazedListTreeRowModel<DataRow>( treeData ), true );
        ViewportLayer viewportLayer = new ViewportLayer( treeLayer );

        ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer( columnHeaderDataLayer, viewportLayer, selectionLayer );

   SortHeaderLayer<DataRow> sortHeaderLayer = new SortHeaderLayer<DataRow>( columnHeaderLayer, sortModel, false );

 GridLayer gridLayer = new GridLayer( viewportLayer, filterRowHeaderLayer, rowHeaderLayer, cornerLayer, false );
        gridLayer.addConfiguration( new GridLayerConfiguration( gridLayer ) );
        m_grid = new NatTable( parent, gridLayer, false );



So I have a SpanningDataLayer with SpanningDataProvider, but I do not where to fit it in the tree grid layers. Any thoughts?
Re: Merged columns in a tree grid [message #1402858 is a reply to message #1402263] Thu, 17 July 2014 21:03 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Well, of what type is your m_dataLayer? Is it not possible to exchange that to the SpanningDataLayer? Or create a custom DataLayer that adds the spanning?
Previous Topic:Mouse Event for certain Layer
Next Topic:Best way to apply dynamic styling in 1.1
Goto Forum:
  


Current Time: Tue Mar 19 07:41:03 GMT 2024

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

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

Back to the top