简体   繁体   中英

GWT CellTable sorting - how to use sorted values?

I've created a ListHandler and I'm overiding its setComparator method to provide a basic alphabetical sort of each TextColumn in my CellTable .

Here's an example of one such sort:

private void createTargetColumnSortHandler()
    {
    ListHandler<RegradeRule> targetColumnHandler = new ListHandler<RegradeRule>(resultsTableDataProvider.getList());
    targetColumnHandler.setComparator(this.targetPromotionColumn, new Comparator<RegradeRule>()
        {
        @Override
        public int compare(RegradeRule o1, RegradeRule o2)
            {
            if (o1 == o2)
                {
                return 0;
                }
            // Compare the name columns.
            if (o1 != null)
                {
                return (o2 != null) ? o1.getTargetPromotion().compareTo(o2.getTargetPromotion()) : 1;
                }
            return -1;
            }
        });
    this.resultsTable.addColumnSortHandler(targetColumnHandler);
    }

In the GUI, after clicking a column to initiate a sort, how can I retrieve the sorted values? Or to rephrase, what stores the sorted values? When debugging I can't seem to catch this click event (or can't find a suitable breakpoint ), therefore I can't find the sorted values - for example, if it's the ListDataProvider used in my CellTable

Edit The CellTable is rendering the sorted values perfectly. I just want to use the sorted values and export to Excel (I can export the un-sorted values just fine)

ListHandler will sort the list that you provide in the constructor. You have passed the list backed by the ListDataProvider , so you will find your sorted list there:

resultsTableDataProvider.getList();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM