Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Moving rows in NatTable when its in sorted state
Moving rows in NatTable when its in sorted state [message #985637] Thu, 15 November 2012 15:07 Go to next message
Raptor X is currently offline Raptor X
Messages: 24
Registered: November 2012
Junior Member
In our application we have an option to move the selected rows in the table to top. we are using NatTable with glazed list. But when the table is in sorted state we cannot move rows in it because glazed list maintains its sort order. Apparently its OK, but in some cases it can be problematic.

IMHO, after a NatTable has sorted itself it should now behave exactly like a normal table as it was before sorting i.e now the event list should change and get aligned with the filter list ( or you can call sorted list ). For the user sorting has changed nothing but the order of rows and this shouldn't restrict the user from moving rows

STATE 1
Before sorting
Event List A,B,C,E,D
Filter List A,B,C,E,D

I can move rows in filter list


STATE 2
After sorting
Event List A,B,C,E,D
Filter List A,B,C,D,E

Now I cannot move items in filter list.

But ideally, after sorting list should just change order of the items and enter a normal state where we can move rows and move E to start as I can do in state 1


JTable is a good example in which we can move rows after applying sort.


Any comments...



Asim
Re: Moving rows in NatTable when its in sorted state [message #985667 is a reply to message #985637] Thu, 15 November 2012 16:14 Go to previous messageGo to next message
Thomas  Mäder is currently offline Thomas Mäder
Messages: 46
Registered: July 2009
Member
Hi Asim,

I don't think the behaviour you want makes sense with the visual language NatTable uses for sorting. In my opinion ,the little triangles in the header clearly indicate a state. The table IS sorted. What you want is more like an action: "Sort the table now!". If you sort the table by column A and then completely reorder the rows, does it still make sense to indicate that the column is sorted by A?
To implement the behaviour you want, you can just implement your own ISortModel. Use a regular list instead of a sorted list and sort it with Collections.sort(). But I don't think it should be the general case.
Re: Moving rows in NatTable when its in sorted state [message #985689 is a reply to message #985667] Thu, 15 November 2012 17:17 Go to previous messageGo to next message
Raptor X is currently offline Raptor X
Messages: 24
Registered: November 2012
Junior Member
Hi Thomas,
Thanks for the prompt reply.
This is debatable that this makes sense or not with the visaul presentation, but the thing I was trying to express was sorting a table should not restrict user from using any other functionality.

I sort the the table on a columns, rows get ordered and column header icon shows that column is sorted - agreed... but now if I want to move the rows there should be some method that removes the sort icon from header, donot move the rows ( keep them as they were after sorting ) and sets the table into normal mode with the sort order as a new order, now user can move rows as s/he wants.

A,B,C,E,D -> Normal state
A,B,C,D,E -> ASC Sorted State , up icon appears
E,D,C,B,A -> DESC sorted state , down icon appears

Suppose I want to move rows when i am in ASC sorted state. I should ask nattable to remove the up icon, make this order of rows the normal state

A,B,C,D,E -> Normal state

Now user will see the rows as sorted but no sort icon on header coz we programatically made this sorted state a normal state


This is just a vague idea. Of course NatTable team cannot change it for me but this behavior can be annoying for many users when it comes to moving the
rows in a table. There should be some work around ( other then giving my own sort model Smile )


Asim
Re: Moving rows in NatTable when its in sorted state [message #985794 is a reply to message #985689] Fri, 16 November 2012 08:23 Go to previous message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1289
Registered: July 2012
Senior Member
Hi Asim,

this is indeed a valid requirement, although it's quite special. You might have recognized that we didn't event support drag&drop of rows, neither does well known spreadsheet applications support such a feature. Wink

Nevertheless, you can achieve such a behaviour with NatTable if you implement the drag&drop yourself (which you might have done already, otherwise this post wouldn't exist). Unfortunately this doesn't work with GlazedLists, as

Quote:
The SortedList will provide a sorted view of the issues list

(quote out of the GlazedLists documentation http://www.glazedlists.com/documentation/tutorial-100#TOC-Sorting-Tables-Sorting-Tables).

This means, by using the SortedList, in my understanding the wrapped baselist isn't really sorted. You only get a sorted view of that list.

So Thomas's suggestion is indeed the correct answer to your request. You will have to use a custom ISortModel and avoid the usage of GlazedLists for this special requirement. This way you are able to "really" sort the list and then drag&drop rows to do a manipulation of the ordering within the list.

I haven't debugged that into more detail, feel free to correct me at this point.

Greez,
Dirk

[Updated on: Fri, 16 November 2012 08:36]

Report message to a moderator

Previous Topic:Mark same column values by the same color
Next Topic:MouseOver, MouseOut listeners for Tablecells possible?
Goto Forum:
  


Current Time: Sat Sep 20 14:00:28 GMT 2014

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

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