i am implementing a tableviewer that is able to sort values depengin on their column order. e.g. column1-column2-columnX sorts the rows first on the values of column 1, then column 2, column....
Therefore i want to use a ColumnViewerSorter, especially the method "int doCompare(Viewer viewer, Object e1, Object e2);"
insid开发者_Python百科e this method i want to sort depending on other Tableviewer Row/Cells for comparison and the difficulty is that JFace tableviewer does the sort in the view only, so i have to "ask" the tableviewer itself for the actual value of e.g. "column 1, row 20"
using the function "viewer.getElementAt(index)" inside "docompare" wold be ok, but inside docompare i do have no reference to the objects e1 and e2 position in the tableviewer.
how could i achieve that?
thanking you very much in advance for helping me
best regards,
Malcom
You could iterate through all items in the table viewer and see where the objects e1 and e2 are, of course.
BUT... and I hope I understand your problem correctly... why do you want to implement multisorting?
Let's say you have 3 columns:
Col1 Col2 Col3
-------------------------
a2 b1 c4
a1 b2 c1
a2 b1 c3
To obtain the sorting order Col1-Col2-Col3, the user can click on Col3, then on Col2, and in the end Col1:
Col1 Col2 _Col3_
-------------------------
a1 b2 c1
a2 b1 c3
a2 b1 c4
Col1 _Col2_ Col3
-------------------------
a2 b1 c3
a2 b1 c4
a1 b2 c1
_Col1_ Col2 Col3
-------------------------
a1 b2 c1
a2 b1 c3
a2 b1 c4
This might not be the best example, but to obtain "multi sorting", the user just has to sort the desired columns in the opposite order.
精彩评论