Flex:数据库驱动的 DataGrid:箭头消失
在 Flex 中,我使用以下代码来允许在 DataGrid 中进行排序(数据在服务器端进行分页和排序)。
private function headerReleaseHandler(event:DataGridEvent):void { var column:DataGridColumn = DataGridColumn(event.currentTarget.columns[event.columnIndex]); if(this.count>0) { if(this.query.SortField == column.dataField) { this.query.SortAscending = !this.query.SortAscending; } else { this.query.SortField = column.dataField; this.query.SortAscending = true; } this.fill(); } event.preventDefault(); }
除了未显示指示排序的箭头之外,这工作得很好。 我怎样才能做到这一点?
谢谢! /尼尔斯
In Flex I'm using the following code to allow sorting in a DataGrid (the data is paged and sorted serverside).
private function headerReleaseHandler(event:DataGridEvent):void { var column:DataGridColumn = DataGridColumn(event.currentTarget.columns[event.columnIndex]); if(this.count>0) { if(this.query.SortField == column.dataField) { this.query.SortAscending = !this.query.SortAscending; } else { this.query.SortField = column.dataField; this.query.SortAscending = true; } this.fill(); } event.preventDefault(); }
This works perfectly, except that the arrows that indicate sorting isn't shown. How can I accomplish that?
Thanks!
/Niels
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果这就是您正在寻找的内容,这里有一个示例:
http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click- a-column/
看起来您需要刷新数据提供者使用的集合。
There is an example here if this is what you are looking for:
http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/
It looks like you need to refresh the collection used by your dataprovider.
我遇到了同样的问题,我找到的唯一解决方案是覆盖 DataGrid 并创建一个自定义的。
类如下:
当您获取 HEADER_RELEASE 事件并设置列索引和方向信息时,您必须专门调用 placeSortArrow() 方法。
I have encountered the same problem and the only solution I found was to override the DataGrid and create a custom one.
Here is the class:
You have to specifically call the placeSortArrow() method when you get the HEADER_RELEASE event and set the column index and direction information.
在上面的代码中,“this”指的是数据网格,因为我对 this.query.SortField 感到困惑,我假设“this”和“query”是您自己的自定义对象。以及您为什么要检查计数。这算什么
。
-莫汉
in the above code what does "this" refer to is it the datagrid because I am confused by this.query.SortField , I am assuming 'this' and "query' are your own custom objects. and why are you checking for count. what count is that.
Regards
-Mohan