Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Resize NatTable on collapse and expand(I would like NatTable to dynamically adjust its size according to its visible contents.)
Resize NatTable on collapse and expand [message #1695515] Fri, 15 May 2015 14:35 Go to next message
Shane Mills is currently offline Shane MillsFriend
Messages: 9
Registered: May 2014
Junior Member
Hi community,

we are currently working on a quite big rcp project and in my role as Software Architect I am evaluating NatTable as a potential solution for a variety of different use cases.

Although NatTable appears to be pretty complex when approaching it for the first time, there do not seem to be many alternatives to realize the high expectations of our usability designers.

I am trying to have NatTable dynamically adjust its height according to the visible contents of the underlying DataLayer. In this case we have a TreeLayer, so we are able to expand and collapse elements that have children.

Everything good so far, except from the fact, that I cannot find an appropriate mechanism to resize NatTable when elements get expanded or collapsed.

The requirement here is, that there should be no scrollbars and NatTable should not be bigger than needed to display all currently visible elements, since there will be multiple NatTable instances and certain other Widgets in the same Part.

Scrolling will be done by the Part itself.

So my question: Is there a way to tell NatTable to recalculate its height based on the current height of its content? And what would be the appropriate way to trigger this mechanism when the contents height changes?

By the way: Resizing of Row heights is deactivated and does not need to be considered for this case.

Thanks in advance for supporting my thinking and learning process Smile

Re: Resize NatTable on collapse and expand [message #1695527 is a reply to message #1695515] Fri, 15 May 2015 17:43 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
I'm not sure about your requirement, but it sounds like you need to listen to create an ILayerEventHandler for StructuralChangeEvents that performs layout operations on the NatTable control. But if I understand you correctly, you don't need the ViewportLayer in your composition.
Re: Resize NatTable on collapse and expand [message #1695612 is a reply to message #1695527] Mon, 18 May 2015 06:22 Go to previous messageGo to next message
Shane Mills is currently offline Shane MillsFriend
Messages: 9
Registered: May 2014
Junior Member
Thank you for you reply Dirk,

I already figured out, that the ViewportLayer was obsolete due to the requirements.

Your suggested solution with the ILayerEventHandler for structural changes was exactly what I was looking for.

What I now do is just setting the Dimensions of the NatTable via natTable.setSize(...). It works perfectly, at least as far as I can see.
Is this the preferred way to dynamically change the layout of the NatTable, or could this mess up internal behavior in any way?

Thank you very much for your support so far Dirk.

Shane
Re: Resize NatTable on collapse and expand [message #1695616 is a reply to message #1695612] Mon, 18 May 2015 07:20 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
Quote:
Is this the preferred way to dynamically change the layout of the NatTable


It is the first time that I hear of somebody who is using NatTable that way. Usually the amount of data shown in a NatTable is bigger than the available space. Therefore dynamic layout calculations to shrink the NatTable if there are less items available than space are rare.

So it is hard to say if that is the "preferred" way. If it works for you it is ok. And I am not aware of another way right now.

Quote:
could this mess up internal behavior in any way?


I don't think it would mess up anything, because your are changing the dimensions of the Canvas that NatTable paints on.

[Updated on: Mon, 18 May 2015 07:21]

Report message to a moderator

Re: Resize NatTable on collapse and expand [message #1696371 is a reply to message #1695616] Tue, 26 May 2015 07:32 Go to previous message
Shane Mills is currently offline Shane MillsFriend
Messages: 9
Registered: May 2014
Junior Member
Sorry for the late reply and thanks a lot for yours Smile

I experienced, that only setting the size of the NatTable in the suggested way will not update its layout correctly and thus lead to unwanted layouting issues.

Instead of using the setSize method I tried to alter the heightHint of the NatTables layout data itself and it works fine for now, or at least I did not run into problems with this solution so far.

This allows me to have more than one NatTable on a single part with each NatTable only showing the currently visible rows and updating their height according to expand and collapse events.

For this I have registered an ILayerEventHandler for RowStructuralChangeEvents updating the layout data of the according NatTable.

Thank you very much for your support Dirk!

Shane
Previous Topic:ColumnReorderLayer writes to System.err
Next Topic:set Custom icon in table column HeaderMenu(popup menu)
Goto Forum:
  


Current Time: Sun Mar 07 15:50:34 GMT 2021

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

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

Back to the top