Thursday, April 25, 2013

Re: columnSortHandler on a Dynamic CellTable

Thank you very much!

Le mercredi 24 avril 2013 15:54:06 UTC-4, sebastie...@isen-lille.fr a écrit :
Hi everybody,

I create a dynamic CellTable this way:

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

final ListDataProvider<List<String>> provider = new ListDataProvider<List<String>>(rows);
provider.addDataDisplay(table);

for (String row: rowsArray) {
rows.add(Arrays.asList(row));}

It works well, but I want to add comparator to my table. So I do that, but it doesn't work:


ListHandler<List<String>>(rows); 

i=0;
while(i<table.getColumnCount()){
columnSortHandler.setComparator(table.getColumn(i),
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(0).compareTo(o2.get(0)) : 1;
                                    }
});
i=i+1;
}
 
table.addColumnSortHandler(columnSortHandler);

i=0;
while(i<table.getColumnCount()){
table.getColumnSortList().push(table.getColumn(i));
i=i+1;
}

I know that the problem is here, but I don't know how to what I want.
 if (o1 != null) {
return (o2 != null) ? o1.get(0).compareTo(o2.get(0)) : 1;
 

Any ideas?

Thanks a lot!

--
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