Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Autoresize command
Autoresize command [message #1231222] Tue, 14 January 2014 05:12 Go to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013

I am trying to use the nattable grids autoresize command and it works except that it does not resize the header row's column width. Is there something that I am doing wrong?

	nt.addListener(SWT.Paint, new Listener()
			            boolean resized = false; 
                        public void handleEvent( Event event )
                            if ( resized )
                            resized = true;
                            for ( int i = 0; i < nt.getColumnCount(); i++ )
                                InitializeAutoResizeColumnsCommand columnCommand = new InitializeAutoResizeColumnsCommand( nt.getLayer(), i, nt.getConfigRegistry(), new GCFactory( nt ) );
                                nt.doCommand(new AutoResizeColumnsCommand( columnCommand ) );
					} );

Initially i tried only InitializeAutoResizeColumnsCommand and later read the documentation on AutoResizeColumnsCommand but it does not work either.
Re: Autoresize command [message #1231263 is a reply to message #1231222] Tue, 14 January 2014 07:58 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2353
Registered: July 2012
Senior Member
it does not resize the header row's column width

I guess you mean the row header column width, right?

The reason is quite easy, the row header does not support auto resizing. This is because the InitializeAutoResizeColumnsCommandHandler is registered against the SelectionLayer. And the AutoResizeColumnCommandHandler that is registered against the GridLayer is performing position-index transformation against the body layer stack.

To provide auto resizing of the row header you will need to implement a custom command and command handler that fits your needs. You could have a look at the current implementations and copy/modify them to not performing position-index transformations for example.

I usually suggest to not calling auto resize at startup but configure the sizes correctly or useing TextPainter that calculate their width. That fits better into a virtual table approach and does not cause performance issues.
Previous Topic:Issue with RowSelectionProvider
Next Topic:Problem with new dropdown when I click on something else
Goto Forum:

Current Time: Mon Feb 27 02:03:16 GMT 2017

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

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