Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Row numbers are also changed , when rows are reordered using row reorder layer
Row numbers are also changed , when rows are reordered using row reorder layer [message #1136972] Mon, 14 October 2013 07:20 Go to next message
SD Khan is currently offline SD KhanFriend
Messages: 63
Registered: May 2013
Member
Hi,

When i move the rows using row reorder layer, then the row number appearing on the Row header layer also get changed. I have verified it by running example "_543_ColumnAndRowReorderExample.java". For example if i have three rows i.e

1 Row1
2 Row2
3 Row3

Now, i move Row2 to Row3 then it becomes (Data change correctly, but row numbers are not)

1 Row1
3 Row3
2 Row2


As for my scenario i wants, and generally i think it should be like this.

1 Row1
2 Row3
3 Row2


Is the above behavior is work as designed or a bug ?


Regards,
SDKhan
Re: Row numbers are also changed , when rows are reordered using row reorder layer [message #1137030 is a reply to message #1136972] Mon, 14 October 2013 08:10 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
This works as intended. Again, the RowReorderLayer "DOES NOT REORDER THE UNDERLYING LIST". You are just reordering the visualization. So the default behaviour is to also show this fact in the ui. But that is just the default behaviour. NatTable as a framework is flexible enough to change that behaviour to fit your needs. Smile

To change this the way you want, you need to use your own rowheader dataprovider instead of using the DefaultRowHeaderDataProvider. The DefaultRowHeaderDataProvider returns the row index +1. You want to show the row position +1. And you can do this by making use of the RowReorderLayer like this for example:
...
final RowReorderLayer rowReorderLayer = new RowReorderLayer(columnReorderLayer);
...
IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider) {
	@Override
	public Object getDataValue(int columnIndex, int rowIndex) {
		return rowReorderLayer.getRowPositionByIndex(rowIndex)+1;
	}
};
...
Previous Topic:Collapse All Rows in TreeLayer
Next Topic:How to correctly use ButtonCellPainter?
Goto Forum:
  


Current Time: Fri Apr 26 17:01:26 GMT 2024

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

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

Back to the top