问题
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? i.e. 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.
回答1:
You have to set sortableColumns
to false and handle the headerRelease
event, where you do the sorting manually on the data source.
<mx:DataGrid sortableColumns="false" headerRelease="onHeaderRelease(event)" ...
回答2:
just call Object(owner).dataProvider.disableAutoUpdate()
before committing the value in your item editor.
回答3:
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
来源:https://stackoverflow.com/questions/5228933/how-to-disable-automatic-sorting-in-editable-datagrid-in-flex-4