简体   繁体   中英

How to disable automatic sorting in Editable Datagrid in Flex 4

I have an editable datagrid. If sorting is applied by clicking any header of datagrid, it works fine. But after that, if data values are changed in any row of datagrid, sorting is applied automatically. How to prevent from this behaviour? ie sorting should only be applied if user clicks on any header of datagrid and sorting should not be applied when user modifies data in grid.

您必须将sortableColumns设置为false并处理headerRelease事件,您可以在其中手动对数据源进行排序

<mx:DataGrid sortableColumns="false" headerRelease="onHeaderRelease(event)" ...

只需在项目编辑器中提交值之前调用Object(owner).dataProvider.disableAutoUpdate()

I know that you're asking this issue in Flex 4 but I hope the solution that I found in Flex 3 will help.

I also had the same exact problem but then I realized that something in the data must be triggering the sorting to happen. And it turned out that I was setting the data to be [Bindable]. This made sense to see sorting happened automatically because the value change dispatch propertyChange event.

If you do need to make the data to be [Bindable], use custom binding: http://livedocs.adobe.com/flex/3/html/help.html?content=ascomponents_4.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM