Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Automatic row resizing(problem resizing rows at bottom of a table)
Automatic row resizing [message #1088201] Fri, 16 August 2013 18:54 Go to next message
Brent Weatherly is currently offline Brent WeatherlyFriend
Messages: 2
Registered: August 2013
Junior Member
Greetings

I know that there has been some discussion about automatically resizing rows and columns, and I'm also aware that this is probably not formally supported. However, implementation options exist, and we have an application that includes images in the table and thus requires row and column resizing.

Long story short, I have a reasonably functional implementation in place, but I'm having issues resizing the last 1-2 rows of a table when the table is larger than the size of the viewport. The code iterates over all rows in the selection layer, converts the selection layer row position to that of the viewport, and then creates and runs an "InitializeAutoResizeRowsCommand" command. It works for all rows except the last 2.

Doing a fair amount of digging, it seems to be related to the height of the column header. I created my own "CompositeLayer" that does not include a column header (or corner layer) and all rows resize correctly. When I use the standard "2x2" GridLayer, it fails.

I have screen shots and the code if anyone is interested. Does anyone have any ideas?

Thanks

Brent
Re: Automatic row resizing [message #1088670 is a reply to message #1088201] Sat, 17 August 2013 12:50 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Hi,

Well it is not completely correct that we don't support automatic resizing. Iterating over the whole table simply violates the virtual nature.

But even this is solved for quite a while in the TextPainter. There you are able to configure whether the row and/or the column should be resized dependent on the content. As the resize only gets triggered on rendering, this solution doesn't violate the virtual nature of NatTable.

This behavior is currently only implemented in the TextPainter. In your case it needs to be added to the ImagePainter too. So I would suggest to extend the ImagePainter to be able to configure if the cell should be automatically resized if the content doesn't fit in the bounds.

You can have a look at the TextPainter to get an idea of what I mean. As I'm currently on vacation I can't implement it together with examples now. But maybe my explanation helps and you are willing to contribute. Definitely this would be nice for NatTable core too.

Greez,
Dirk
Re: Automatic row resizing [message #1091560 is a reply to message #1088670] Wed, 21 August 2013 17:06 Go to previous messageGo to next message
Brent Weatherly is currently offline Brent WeatherlyFriend
Messages: 2
Registered: August 2013
Junior Member
Thanks for the tip Dirk. I was able to get this working using a combination of the iterative "move into viewport" followed by auto-resize PLUS the modified ImagePainter. The reason I do both is that the iterative method on the whole table works for about 95% of cases (at least for me), and in so doing automatically expands the column width to the size of the largest image (or text). Then, as the user scrolls, the CellPainter will verify that the content fully fits in cell, expanding where necessary. I did not like the implementation of the CellPainter alone, as it can make scrolling choppy as you scroll down and columns/rows are resized. Plus, since the ImagePainter is created for each image (unlike the TextPainter which is for the whole table), you cannot recenter the image in a column if the width expands. At least, I didn't easily see how to resolve that.

Let me know if you'd like to see any of the code.

Cheers
Re: Automatic row resizing [message #1091671 is a reply to message #1091560] Wed, 21 August 2013 20:56 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Quote:
it can make scrolling choppy as you scroll down and columns/rows are resized


Yup, that's the downside of a virtual table Smile

Quote:
the ImagePainter is created for each image


Not necessarily, if you have a look at the ImagePainter implementation you will notice that it is also possible to register only one ImagePainter for the whole table and change the style configuration which could contain the image as cell style attribute CellStyleAttributes.IMAGE.

Quote:
Let me know if you'd like to see any of the code


Definitely yes! Maybe there is a way to get things included into NatTable Core.
Previous Topic:remove data when table is sorted
Next Topic:Tree level summary rows
Goto Forum:
  


Current Time: Thu Mar 28 09:28:40 GMT 2024

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

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

Back to the top