Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gwt 可排序单元格列的标题没有响应_Gwt_Celltable - Fatal编程技术网

Gwt 可排序单元格列的标题没有响应

Gwt 可排序单元格列的标题没有响应,gwt,celltable,Gwt,Celltable,我正在使用GWT2.5创建一个带有可排序日期列的CellTable 我的代码如下: CellTable<Activity> table = new CellTable<Activity>(); table.setRowStyles(new RowStyles<Activity>() { @Override public String getStyleNames(Activity row, int rowIndex) { ret

我正在使用GWT2.5创建一个带有可排序日期列的CellTable

我的代码如下:

CellTable<Activity> table = new CellTable<Activity>();

table.setRowStyles(new RowStyles<Activity>() {
    @Override
    public String getStyleNames(Activity row, int rowIndex) {
        return TABLE_ROW_STYLE_NAME;
    }
});

// create date column
TextColumn<Activity> dateColumn = new TextColumn<Activity>() {
    @Override
    public String getValue(Activity a) {
        return dateFormat.format(a.getDate());
    }
};
dateColumn.setSortable(true);
dateColumn.setDefaultSortAscending(false);
// add column to table
table.addColumn(dateColumn, myConstants.dateColumnHeader());

// attach provider to table
activityProvider.addDataDisplay(table);

// create sort handler
ListHandler<Activity> sortHandler = new ListHandler<Activity>(activityProvider.getList());
sortHandler.setComparator(dateColumn, new Comparator<Activity>() {
    @Override
    public int compare(Activity a1, Activity a2) {
        if (a1 == a2) {
            return 0;
        }

        // compare the date columns
        if (a1 != null) {
            if (a2 != null) {
                long a1Val = a1.getDate().getTime();
                long a2Val = a2.getDate().getTime();
                if (a1Val == a2Val) {
                    return 0;
                }
                else if (a1Val > a2Val) {
                    return 1;
                }
                else {
                    return -1;
                }
            }
            else {
                return 1;
            }
        }

        return -1;
    }
});

// add sort handler to table
table.addColumnSortHandler(sortHandler);

// add date column to table's sort list
table.getColumnSortList().push(dateColumn);

table.setWidth("100%");

getView().getActivityPanel().add(table);
CellTable.

这是我使用的:

    dateColumn.setSortable(true);
    sortHandler.setComparator(dateColumn, new Comparator<ObjectPobject>() {
        public int compare(ObjectPobject o1, ObjectPobject o2) {
            return o1.getDate().compareTo(o2.getDate());
        }
    });
dateColumn.setSortable(true);
setComparator(dateColumn,new Comparator(){
公共整数比较(ObjectPobject o1,ObjectPobject o2){
返回o1.getDate().compareTo(o2.getDate());
}
});
应该是

a1.getDate().getTime().compareTo(a2.getDate().getTime())

a1.getDate()之后(a2.getDate())


发生这种情况是因为GWT使用JavaScript比较,而compareTo对日期不起作用。

这是与上面相同的comparator,只是您没有检查null。一个问题:您使用的是什么版本的gwt?我认为2.5RC1中的列排序可能会被打破,但取消比较并没有解决问题:(我使用与您相同的代码,并且我的列排序很好。我使用2.5RC1。我也有同样的问题,我猜这与加载的jQuery Mobile JS有关?!如果我调用
table.getColumnSortList().push(someStringColumn)
它显示在列上按降序排序的表格。在列标题鼠标选择时,在标题和正文列周围绘制了一些选择边框,并且未显示排序图标。单击正文区域,然后删除此选择,显示正确的排序方向指示灯更改,但不会对表格进行排序:-(在添加了一些调试之后,既不调用
Comparator.compare(…)
也不调用
Column.getValue(…)
,-/…但在t正文行单元格单击时调用
getValue(…)
)。