对CellTable服务器端进行排序 [英] Sorting a CellTable server-side

查看:129
本文介绍了对CellTable服务器端进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Gwt CellTable,通过RPC调用绑定到我的GAE / Objectify后端。



现在就行! : - )

然后我想对列进行排序,所以我阅读 http://code.google.com/intl/it-IT/webtoolkit/doc/latest/DevGuideUiCellTable.html#columnSorting



异步远程排序部分很好地显示了如何排序到我的AsyncDataProvider中,但是...我如何检索用户列的名称想要排序?



它显示以下代码: ColumnSortList sortList = table.getColumnSortList();



但是我怎么能从中得到字符串名?我只是想知道姓氏或soldDate,即列所绑定字段的名称!然后我将它传递给我的rpc服务,并使用它对数据服务器端 query(...)。order(< field_name>)



我错过了什么?



UPD :这里有趣的东西: http://groups.google.com/group/google-web-toolkit / browse_thread / thread / 77a0eaf8086218a6 / effb8d3abe69270b#effb8d3abe69270b

解决方案

您可以保留列名在表格中:

 列表< String> columnNames = new ArrayList< String>(); 

table.addColumn(surnameColumn,surname);
columnNames.add(surname);

//添加其他列

然后,当您需要获取排序列名称:

 字符串sortColumnName; 
ColumnSortList sortList = table.getColumnSortList();
if(sortList!= null&&&sort; sort.size()!= 0){
Column< MyEntity,?> sortColumn =(Column< MyEntity,?>)
sortList.get(0).getColumn();
整数columnIndex = table.getColumnIndex(sortColumn);
sortColumnName = columnNames.get(columnIndex);
}

//做你的rpc电话

*其中MyEntity是您的数据对象显示在单元格表中。


I'm currently using a Gwt CellTable, bound to my GAE/Objectify backend via RPC calls.

All right now! :-)

Then I want to sort columns, so I read http://code.google.com/intl/it-IT/webtoolkit/doc/latest/DevGuideUiCellTable.html#columnSorting

The Async Remote sorting sections shows very well how to get sorting into my AsyncDataProvider but... how can I retrieve the name of the column the user wants to sort?

It shows this code: ColumnSortList sortList = table.getColumnSortList();

But how can I get String names from that? I simply want to know "surname" or "soldDate", the name of the field the column is bound to! Then I will pass it to my rpc service, and use it to sort data server-side query(...).order(<field_name>)

Am I missing something?

UPD: interesting stuff here: http://groups.google.com/group/google-web-toolkit/browse_thread/thread/77a0eaf8086218a6/effb8d3abe69270b#effb8d3abe69270b

解决方案

You can keep a list of column names ordered as they are in the table:

List<String> columnNames = new ArrayList<String>();

table.addColumn(surnameColumn, "surname");
columnNames.add("surname");

// add the other columns

Then when you need to get the sort column name:

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

*where MyEntity is your data object displayed in the cell table.

这篇关于对CellTable服务器端进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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