We have grids which shows like this
A B C D1 D2 D3 ... D99 D100
where D1, D2 .... D100 are date columns and A, B, C are some other fields on that record
Requirement:
1. User should be able to reorder fields A, B, C anywhere to the left of D1
2. User should NOT be able to change order of D1, D2, ... D100 at all. The reason is obvious. We do not want to column for April 10 (D5) to show before April 9 (D4)
For requirement 2, I would like to set AllowColMoving to NotAllowed only for D columns to keep them frozen in place. From what I am reading and experiencing, UltraGrid set it for the whole grid or none. If that is indeed the case, what is my option to keep only D column from being moved?
Thanks!
Hi,
The reason AllowColMoving is not available on a per-column basis is that it doesn't really make sense because moving a column which is allowed to move could affect the position of the column that isn't.
So, in this example, even if all of the D columns had AllowColMoving disabled, you could still place Column A in between columns D1 and D2, and thus change the position of column D1.
So your best bet here is to use the BeforeColPosChanged event and examine the new column positions and set e.Cancel to true if the user does something you don't like. :)
With BeforeColPosChanged, I notice I can still move the column but the handler's cancel puts it back in place. That may be acceptable for the user but is not as nice as if the date "D" columns were frozen in place
I seemed to be able to achieve the "freezing" effect by doing to to each "D" column
dcolumn.Layout.Override.HeaderClickAction = HeaderClickAction.Select;
dcolumn.Layout.Override.SelectTypeCol = SelectType.None;
What do you say?
I am noticing the following side effects
1. The D column can no longer be sorted
2. Even the non date columns i.e. A, B, C are frozen in place and they are not sortable either.
Any ideas on how I can get rid of the side effects, esp #2
vrn said:With BeforeColPosChanged, I notice I can still move the column but the handler's cancel puts it back in place. That may be acceptable for the user but is not as nice as if the date "D" columns were frozen in place
I agree, this is not as nice. Ideally, what you really want is an event that fires when the user tries to initiate a drag, so you could cancel it based on which columns are about to be dragged. And another event that fires as the column(s) is dragged so you can evaluate whether or not the current position is valid.
There are no such events in the grid currently. But I encourage you to Submit a feature request to Infragistics. And perhaps this can be added in a future release.
Regarding your workaround, I don't think this will work. the Layout is a backward pointer, so you are setting HeadlerClickAction and SelectTypeCol on every column, not just the dcolumn.
Perhaps an alternative would be to use the MouseMove event of the grid. You could determine which column header (if any), that the mouse is currently over and set AllowColMoving. To determine which column the mouse is over, you can use this:
HOWTO:UltraWinGrid Mouse Position and Column Identification