Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Sorting Not honoring applied style labels(On single click sort the applied column labels are not getting arranged correctly)
Sorting Not honoring applied style labels [message #1808325] Fri, 21 June 2019 14:18 Go to next message
Shreya Suman is currently offline Shreya SumanFriend
Messages: 13
Registered: March 2017
Junior Member
index.php/fa/35792/0/Experts,

I have a nattable implementation , where few cells in some of the rows are made non editable; highlighted in yellow in attached image(beforeSort.jpg).

my nattable has single click sort configuration. when i click on column header to sort the table rows, the data is getting sorted correctly, but the labels not re-arranged, instead the labels are still showing up at the same cell position as they were before sorting.
i want my labels to also get moved to the new sorted location of the row.

i am applying label by overriding the getConfigsLabelByPosition method from bodyDataProvider. Sample Code is attached.
Same issue also observed with Filtering.

Can you please help me to achieve this.

index.php/fa/35792/0/

index.php/fa/35790/0/
Re: Sorting Not honoring applied style labels [message #1808326 is a reply to message #1808325] Fri, 21 June 2019 14:30 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I haven't looked into your sources directly, but from their names and screenshots I suppose you have the same issue as reported here

https://www.eclipse.org/forums/index.php/t/1099331/

I assume you use a new IDataProvider in the label accumulator that doesn't match the body data provider. You should use the same instance in all places.
Re: Sorting Not honoring applied style labels [message #1808372 is a reply to message #1808326] Sat, 22 June 2019 10:35 Go to previous messageGo to next message
Shreya Suman is currently offline Shreya SumanFriend
Messages: 13
Registered: March 2017
Junior Member
Hello Dirk,

my example is slightly different from the one you mentioned. I am overriding the getConfigLabelsByPosition from my body data layer .
My Code to build data provider and apply labels is as below:

EventList persons =
GlazedLists.eventList(people);
SortedList sortedList =
new SortedList<>(persons, null);

IColumnPropertyAccessor accessor =
new ReflectiveColumnPropertyAccessor<>(propertyNames);

IDataProvider bodyDataProvider =
new ListDataProvider<>(sortedList, accessor);

DataLayer bodyDataLayer = new DataLayer(bodyDataProvider)
{
@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
{
LabelStack result = super.getConfigLabelsByPosition(columnPosition, rowPosition);
int rowIndex = getRowIndexByPosition(rowPosition);
int colIdx = getColumnIndexByPosition(columnPosition);
SimplePerson data = (SimplePerson)persons.get(rowIndex);

if(data.getId() >120 && colIdx ==2)
{
result.addLabelOnTop(NON_EDITABLE_LABEL);
}

return result;

}
};

GlazedListsEventLayer eventLayer =
new GlazedListsEventLayer<>(bodyDataLayer, sortedList);

SelectionLayer selectionLayer =
new SelectionLayer(eventLayer);
ViewportLayer viewportLayer =
new ViewportLayer(selectionLayer);


i dont have any other instance of BodyDataProvider.
i think the styles that are being applied are for a particular cell position, and on sorting the cell styles are not re-evaluated based on new row positioning after sort.

Is there a way to achieve this. as my custom style labels are based on particular value in that row.
Re: Sorting Not honoring applied style labels [message #1808373 is a reply to message #1808372] Sat, 22 June 2019 12:36 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Maybe your example is slightly different, but you make the same mistake. You show the SortedList but you perform your check on the base list. The sorting is applied on the SortedList so you need to perform the checks on the SortedList, not on persons.
Previous Topic:Labels not working with sorting
Next Topic:How to get notified, that the DataLayer has finished loading data
Goto Forum:
  


Current Time: Thu Apr 25 17:10:07 GMT 2024

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

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

Back to the top