Wednesday, April 24, 2013

Re: columnSortHandler on a Dynamic CellTable

In https://groups.google.com/forum/?start=&hl=en#!topic/google-web-toolkit/7CFHEhWUjQA[1-25-false]

I don't know what is "verbColumn" in my exemple.

I try to do the same thing, but I don't know how can this example can works because k is not "final"!

My try:

ListHandler<List<String>> columnSortHandler = new 
ListHandler<List<String>>(rows);

for (int column = 0; column < arrListFilters.size(); column++) {
IndexedColumn IColumn= new IndexedColumn(column);
IColumn.setSortable(true);
table.addColumn(IColumn, arrListFilters.get(column));

columnSortHandler.setComparator(IColumn, new Comparator<List<String>>() {
public int compare(List<String> o1, List<String> o2) {
          if (o1 == o2) {
            return 0;
          }
          // Compare the column.
          if (o1 != null) {
            return (o2 != null) ? o1.get(column).compareTo(o2.get(column)) : 1;
          }
          return -1;
    }
I have an error, "column" is not final..."Cannot refer to a non-final variable column inside an inner class defined in a different method"

Le mercredi 24 avril 2013 17:24:08 UTC-4, sebastie...@isen-lille.fr a écrit :
Thanks for your answer.

I didn't know what to do, so I test with the 0th entry. I know that it is not the solution. 

In your answer, columnIndex is my "i" I guess? I can't get it, it must be "final". 

I try to do that, but it doesn't work too:

i=0;
while(i<table.getColumnCount()){
final Column<List<String>, ?> column= table.getColumn(i);
columnSortHandler.setComparator(column,new Comparator<List<String>>() {
public int compare(List<String> o1,List<String> o2) {
if (o1 == o2) {
return 0;
}
if (o1 != null) {
return (o2 != null) ? o1.get(table.getColumnIndex(column)).compareTo(o2.get(table.getColumnIndex(column))) : 1;
}
return -1;

}
});
i=i+1;
}

Le mercredi 24 avril 2013 16:24:36 UTC-4, Jens a écrit :
Why do you always compare the 0th entry? Shouldn't it match the column the comparator is responsible for, e.g. o1.get(columnIndex).compareTo(o2.get(columnIndex))?

-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment