Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
150
Dynamically move a "named" column when a Grid row is expanded...
posted

Hi, I'm using XamDataGrid to bind to a list of data items at runtime, so I can't predict the field layout in advance. I'm alowing the Grid to generate it automatically from the public properties on the data items.   Some of the data items may contain properties that are Lists of other objects, which will cause the grid to generate a nested grid - (discovering the nested columns as the rows are expanded) which is exactly what I want.

However... I need some control over the field order, so if any data item (even the nested items) contains a public property called "ID" I always want that displayed as the first column. I can move the column in the outer most grid when the grid is being initially created, but my problem specifically relates to the case of expanding nested grids...

Initially I tried using the Grid.FieldLayoutInitializing event, walking through the grids FieldLayouts and finding and Moving any "ID" column, however the field layout for the expanding grid isn't populated yet...

Next I tried using the Grid.FieldLayoutInitialized event, again walking through the grids FieldLayouts and finding and Moveing an "ID" column, however the column won't move immediately, so the grid displays the column in its original position.

Finally I tried using Grid.AssigningFieldLayoutToItemDirect, rather than getting the grid and walking through all of the FieldLayouts, I use the FieldLayout that is given in the event. Again I find and move an "ID" column if one exists, however the column only moves the second time I expand a nested grid.

Any ideas?