Gwt,CellTable,我怎么知道哪个列用户点击排序? [英] Gwt, CellTable, how can I know which column user clicks for sorting?

查看:136
本文介绍了Gwt,CellTable,我怎么知道哪个列用户点击排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写GWT应用程序

我有CellTable和一个我从谷歌示例代码网站获得的代码。

I have CellTable and a code that i'v got from google-example code-site.

我需要通过点击表的列来实现服务器端排序。

I need to implement server-side sorting by clicking on table's columns.

我的代码是:

AsyncDataProvider<MYOBJECT> dataProvider = new AsyncDataProvider<MYOBJECT>() {
 @Override
 protected void onRangeChanged(HasData<MYOBJECT> display) {
   final Range range = display.getVisibleRange();

   ...
   int sortingColumnIndex = 0;
   boolean isAscending = sortList.get(sortingColumnIndex).isAscending();

   // some server-side call here
 }

那么,我怎么知道用户点击哪一列?即列的标题列的实际索引或用于标识列用户点击的任何内容的实际索引?

So, how can I know which column an user clicks on ? I.e. Real index of column of header of column or anything for identifying that column user clicked?

我只将 HasData显示作为事件,但是似乎还不够确定列。

I have only HasData display as an event, but it seems is not enough to determinate the column.

推荐答案

对CellTable服务器端进行排序

魔术数字0是排序列表中排序列的索引,不是从单元格表的列索引。
所以 sortList.get(0).getColumn()获取用户点击的列。只有当您计划在多列上实施排序时,才必须担心 sortList 中的其他列。

The magic number 0, is the index of the sort column in the sort list, and not the column index from the cell table. So sortList.get(0).getColumn() gets you the column that the user clicked on. You have to worry about the other columns in the sortList only if you plan to implement sorting on multiple columns.

这篇关于Gwt,CellTable,我怎么知道哪个列用户点击排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆