对 2 个不同的数据网格进行排序
Sorting of 2 different datagrids
是否可以同步两个包含相似值列的不同数据网格? (我可以将其放在单个数据网格上,但我打算做其他事情。)
也就是说,如果我对数据网格 1 进行排序,数据网格 2 也会进行排序。
是的。
您可以将 ColumnSortHandler 添加到一个 Datagrid。在此处理程序中,您可以调用 event.getColumn() 来查看哪个列已用于排序,并调用 event.isSortAscending() 来获取排序方向。然后就可以把对应的列push到另一个Datagrid中的排序列表中,并在上面调用排序事件:
tableA.addColumnSortHandler(new ColumnSortEvent.Handler() {
@Override
public void onColumnSort(ColumnSortEvent event) {
Column<MyObject, String> columnA = event.getColumn();
// find columnB in tableB that corresponds to columnA in tableA
tableB.getColumnSortList().push(new ColumnSortInfo(columnB, event.isSortAscending()));
ColumnSortEvent.fire(tableB, tableB.getColumnSortList());
}
});
是否可以同步两个包含相似值列的不同数据网格? (我可以将其放在单个数据网格上,但我打算做其他事情。)
也就是说,如果我对数据网格 1 进行排序,数据网格 2 也会进行排序。
是的。
您可以将 ColumnSortHandler 添加到一个 Datagrid。在此处理程序中,您可以调用 event.getColumn() 来查看哪个列已用于排序,并调用 event.isSortAscending() 来获取排序方向。然后就可以把对应的列push到另一个Datagrid中的排序列表中,并在上面调用排序事件:
tableA.addColumnSortHandler(new ColumnSortEvent.Handler() {
@Override
public void onColumnSort(ColumnSortEvent event) {
Column<MyObject, String> columnA = event.getColumn();
// find columnB in tableB that corresponds to columnA in tableA
tableB.getColumnSortList().push(new ColumnSortInfo(columnB, event.isSortAscending()));
ColumnSortEvent.fire(tableB, tableB.getColumnSortList());
}
});