简体   繁体   English

GWT CellTable排序-如何使用排序值?

[英]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 . 我已经创建了一个ListHandler并且覆盖了它的setComparator方法,以提供CellTable中每个TextColumn的基本字母顺序。

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? 在GUI中,单击列以启动排序后,如何检索排序后的值? 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 调试时,我似乎无法捕捉到此click事件(或找不到合适的breakpoint ),因此无法找到排序后的值-例如,如果它是我的CellTable使用的ListDataProvider

Edit The CellTable is rendering the sorted values perfectly. 编辑 CellTable可以完美呈现排序后的值。 I just want to use the sorted values and export to Excel (I can export the un-sorted values just fine) 我只想使用排序后的值并导出到Excel(我可以导出未排序的值就可以了)

ListHandler will sort the list that you provide in the constructor. ListHandler将对您在构造函数中提供的列表进行排序。 You have passed the list backed by the ListDataProvider , so you will find your sorted list there: 您已经传递了ListDataProvider支持的列表,因此您可以在此处找到排序后的列表:

resultsTableDataProvider.getList();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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