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?
Hello IanLight,
I was just wondering did you have a chance to try my suggestion. If you still need any assistance on the matter, please do not hesitate to ask.
I have been looking through your questions and I can suggest you check the following topic which discuss how you can move the XamDataGrid fields:
http://blogs.infragistics.com/forums/p/64300/325363.aspx
Therefore depending on your requirements you can try implementing this on Loaded event of the XamDataGrid or in the FieldLayoutInitializing event.
Please let me know if you have any additional questions on this, or if I have misunderstand you in any way.
B.T.W. I also tried Grid.AssigningFieldLayoutToItem, same thing - column is only moved the second time a nested grid row is expanded.