views:

45

answers:

2

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 ?

A: 

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.

Gregor Kiddie
Thank you, This event seems to be fired after the columns are set for a swap. i.e. grid.columns[oldIndex] is not the column being moved, but the column on which it is being dropped. Also, how can we stop this event from completing the swap of columns. -- This is not clear yet, I need to explore. Please let me know if you can shed some light on it.
Shah Al
There doesn't seem to be a protected method that corresponds to the event, and the event itself seems to be dispatched after the event. You'll need to monkey patch the DG code to make it work I suspect, there's no good way external to the DG that I can see of stopping the shift.
Gregor Kiddie
:( , I will probably try to swap-back the columns in the event instead of blocking it. Hopefully that should be a good enough work around. Thank you.
Shah Al