Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » ShowCellInViewportCommand on _513_FreezeExample
ShowCellInViewportCommand on _513_FreezeExample [message #1741908] Tue, 30 August 2016 14:33 Go to next message
Apurv Kulkarni is currently offline Apurv KulkarniFriend
Messages: 6
Registered: August 2016
Junior Member
I am new to natTable and I am trying some examples. I want to use ShowCellInViewportCommand. I tried the following code on many examples, it worked except for _513_FreezeExample.
nattable.doCommand(new ShowCellInViewportCommand(
nattable, 3, 7));

After executing the above code, (3, 7) cell is not shown. It is valid cell and Handler is in place. I understand that layer structure is different here.
What should I do to make it work? Please explain.
Re: ShowCellInViewportCommand on _513_FreezeExample [message #1742070 is a reply to message #1741908] Wed, 31 August 2016 05:25 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
That is an issue with regards to the layer composition. As the CompositeFreezeLayer is a CompositeLayer inside a GridLayer (which is also a CompositeLayer), the index-position-transformation for the positions you specify doesn't work well.

If you instead use the viewportLayer as reference layer for the given positions it works. But of course you need to mentally increase the position numbers for the header rows/columns.

natTable.doCommand(new ShowCellInViewportCommand(viewportLayer, 4, 8));
Re: ShowCellInViewportCommand on _513_FreezeExample [message #1742599 is a reply to message #1742070] Tue, 06 September 2016 05:33 Go to previous messageGo to next message
Apurv Kulkarni is currently offline Apurv KulkarniFriend
Messages: 6
Registered: August 2016
Junior Member
Thanks Dirk! Scrolling using ShowCellInViewPortCommand worked Smile

After scrolling, now I'm struggling for position-Index transformation. I tried,
nattable.getColumnIndexByPosition(columnPosition)
and also compositeFreezeLayer.getColumnIndexByPosition(columnPosition)

But getColumnIndexByPosition returns -1 when column = last column
Which layer should I use for position-Index transformation in this case?
Re: ShowCellInViewportCommand on _513_FreezeExample [message #1742601 is a reply to message #1742599] Tue, 06 September 2016 06:17 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
do you consider that positions are 0 based?
Re: ShowCellInViewportCommand on _513_FreezeExample [message #1742603 is a reply to message #1742601] Tue, 06 September 2016 06:54 Go to previous messageGo to next message
Apurv Kulkarni is currently offline Apurv KulkarniFriend
Messages: 6
Registered: August 2016
Junior Member
Yes
Re: ShowCellInViewportCommand on _513_FreezeExample [message #1742611 is a reply to message #1742603] Tue, 06 September 2016 07:30 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Is the columnPosition NatTable based or ViewportLayer based?
Re: ShowCellInViewportCommand on _513_FreezeExample [message #1742625 is a reply to message #1742611] Tue, 06 September 2016 08:22 Go to previous messageGo to next message
Apurv Kulkarni is currently offline Apurv KulkarniFriend
Messages: 6
Registered: August 2016
Junior Member
I'm trying following pseudo code in _513_FreezeExample.
get column count using nattable.getColumnCount()
for (int col = 0; col < columnCount; col++) {
ShowCellInViewportCommand using viewPortLayer
colPos = getColumnPosition(col);
print colPos
}

getColumnPosition(int columnIndex)
{
for (int i = 0; i < columnCount; i++) {
	if (nattable.getColumnIndexByPosition(i) == columnIndex) {
		return i; }
}
return -1;
} 


After this code "02345-1" gets printed.
If I use, viewport or CompositeFreezeLayer in getColumnPosition (i.e.viewportlayer.getColumnIndexByPosition) then "01234-1" gets printed.
What to do if I want "012345"?
Re: ShowCellInViewportCommand on _513_FreezeExample [message #1742628 is a reply to message #1742625] Tue, 06 September 2016 08:32 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Is the last column visible? The ViewportLayer only returns values greater than -1 for visible columns. The intention of the ViewportLayer is to provide a virtual mode that only handles visible cells.
Re: ShowCellInViewportCommand on _513_FreezeExample [message #1742629 is a reply to message #1742628] Tue, 06 September 2016 08:33 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
So probably it works with using the SelectionLayer as that layer has no virtual nature.
Re: ShowCellInViewportCommand on _513_FreezeExample [message #1742745 is a reply to message #1742629] Wed, 07 September 2016 06:53 Go to previous messageGo to next message
Apurv Kulkarni is currently offline Apurv KulkarniFriend
Messages: 6
Registered: August 2016
Junior Member
Unfortunately the last column's position is obtained as -1 even after trying with Selection Layer.
Re: ShowCellInViewportCommand on _513_FreezeExample [message #1742746 is a reply to message #1742745] Wed, 07 September 2016 06:54 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Don't execute the command on the NatTable instance, as this way the command will be processed through the ViewportLayer and therefore the processing stops there. You need to execute it on the SelectionLayer.
Re: ShowCellInViewportCommand on _513_FreezeExample [message #1742855 is a reply to message #1742746] Thu, 08 September 2016 09:00 Go to previous messageGo to next message
Apurv Kulkarni is currently offline Apurv KulkarniFriend
Messages: 6
Registered: August 2016
Junior Member
I'm executing the command on selectionLayer itself.
public int getColumnPosition(int columnIndex) {
		int count = nattable.getColumnCount();
		for (int i = 0; i < count; i++) {
			if (selectionlayer.getColumnIndexByPosition(i) == columnIndex) {
				return i;
			}
		}
		return -1;
	}

I observed that nattable.getColumnCount() = 6.
But AbstractColumnHideShowLayer.getColumnCount() = 5 (called through (selectionlayer.getColumnIndexByPosition). So it is returning -1. Is it expected to happen due to FreezeLayer?
How should I go?
Re: ShowCellInViewportCommand on _513_FreezeExample [message #1742871 is a reply to message #1742855] Thu, 08 September 2016 10:40 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
As far as I remember the FreezeExample uses a GridLayer. It has 5 columns in the body and one row header column. Which makes a total of 6 on NatTable level. Maybe you need to make yourself familiar with the basic NatTable layer concepts first.
Previous Topic:Excel Like coloring facility
Next Topic:Row-height defined via CSS not being applied to data added at runtime
Goto Forum:
  


Current Time: Tue Mar 19 03:31:17 GMT 2024

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

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

Back to the top