2
votes

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 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 ?

2

2 Answers

2
votes

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>
0
votes

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.