Skip to main content



      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 03:20 Go to next message
Eclipse UserFriend
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 04:10 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 17:12:24 EDT 2025

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

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

Back to the top