DevExpress GridControl with dynamic columns and rows

I am working with DevExpress 14.1 GridControl in WPF, which needs to bind to a dynamic source. We don't know the number of columns or rows at design time, so this needs to be calculated on the fly.

The source can be changed on runtime, adding more rows or columns, or BOTH (I can have a table with 3 columns and 5 rows, and the 6th row with 4 columns can be inserted by adding a new column to the model with empty data for the previous lines).

I used a DataTable as the ItemSource for the grid, but it will only load data inserted at design time. If I add columns when the app starts, the grid won't refresh for some reason.

Is there an observable that can satisfy these needs?

+3


source to share


1 answer


Dynamic columns must be created and added to the GridColumncollection programmatically on the fly. They should be unbound .

GridColumn.FieldName Set this property to a unique string that does not match the field name in the underlying grid control.

GridColumn.UnboundType Set this property to a value that identifies the type of data that should be displayed in the column (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 a dataset of unbound cells and get (this one event does both): ColumnView.CustomUnboundColumnData STRONG>

+1


source







All Articles