开发者

flex datagrid columns drag

开发者 https://www.devze.com 2023-01-19 19:51 出处:网络
I have a data grid where users can drag columns and reposition them. But there is a strange requirement that some columns should not be draged to the left of some other column.

I have a data grid where users can drag columns and reposition them. But there is a strange requirement that some columns should not be draged to the left of some other column.

eg, assume the columns are : name, price , start date, end date,

The end date should 开发者_Python百科not be dragged and placed before the start date. i.e. The user can have

  • start date, price , name , end date.
  • name, start date, price , end date.

But at no point can end date appear before start date.

Is there a way to do this flex? Is there a way to know where the user is trying to drop the column and show error message ?


The solution involves a work around.

  • First use a Advanced data grid instead of a Data grid.
  • Then create a column Group and add Start Date and End Date columns to it.
  • Then set childrenDragEnabled="false" in the column group.
  • Thats the work around. Sample code below.

Solution (notice childrenDragEnabled="false"):

<mx:AdvancedDataGridColumnGroup childrenDragEnabled="false">
    <mx:AdvancedDataGridColumn dataField="startDate" />
    <mx:AdvancedDataGridColumn dataField="endDate" />
</mx:AdvancedDataGridColumnGroup>


You need to listen for the headerShift event, check the new index against the indexes of the ones its not allowed to be before, and move it back yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消