Reputation: 159
I'm working with a DevExpress 14.1 GridControl on WPF, which must bind to a dynamic source. We don't know the number of columns or rows on design time, so this must be calculated on the fly.
The source may be changed while executing, adding more rows, or columns, or BOTH (I could have a table with 3 columns and 5 rows, and a 6th row with 4 columns could be inserted, adding a new column to the model with empty data for the previous rows).
I was using a DataTable as ItemsSource for the grid, but it will only load data inserted on design time. If I add columns while running the app, the grid wont update for some reason.
Is there an observable object that can satisfy this needs?
Upvotes: 3
Views: 3858
Reputation: 11
The dynamic columns must be created and added to the GridColumncollection programmatically on the fly. They must be unbound.
GridColumn.FieldName Set this property to a unique string that does not match any field name in the grid control's underlying data source.
GridColumn.UnboundType Set this property to a value that identifies the type of data the column is supposed to display (Boolean, DateTime, Decimal, Integer, String or Object).
To check how GridColumns are created and added see your generated file.
There is a grid event to handle the unbound cells data set and get (It's one event doing both): ColumnView.CustomUnboundColumnData
Upvotes: 1