我目前正在使用 Gwt CellTable,通过 RPC 调用绑定到我的 GAE/Objectify 后端。
现在好了! :-)
然后我想对列进行排序,所以我读了http://code.google.com/intl/it-IT/webtoolkit/doc/latest/DevGuideUiCellTable.html#columnSorting
异步远程排序部分很好地展示了如何排序到我的 AsyncDataProvider 中,但是...我如何检索列名用户想要排序?
它显示了这段代码:ColumnSortList sortList = table.getColumnSortList();
但是我怎样才能从中获取字符串名称呢?我只是想知道“surname”或“soldDate”,列绑定的字段的名称!然后我将它传递给我的 rpc 服务,并用它来对服务器端的数据进行排序query(...).order(<field_name>)
我错过了什么吗?
UPD:这里有趣的东西:http://groups.google.com/group/google-web-toolkit/browse_thread/thread/77a0eaf8086218a6/effb8d3abe69270b#effb8d3abe69270b
您可以按照表中的顺序保留列名称列表:
List<String> columnNames = new ArrayList<String>();
table.addColumn(surnameColumn, "surname");
columnNames.add("surname");
// add the other columns
然后当您需要获取排序列名称时:
String sortColumnName;
ColumnSortList sortList = table.getColumnSortList();
if (sortList != null && sortList.size() != 0){
Column <MyEntity, ?> sortColumn = (Column <MyEntity, ?>)
sortList.get(0).getColumn();
Integer columnIndex = table.getColumnIndex(sortColumn);
sortColumnName = columnNames.get(columnIndex);
}
// do your rpc call
*其中 MyEntity 是单元格表中显示的数据对象。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)