Monday, May 13, 2013

DevExpress WPF Grid - NewRowItem is Evil!

If you need any kind of custom validation or special cross-column logic when you enter a new data (new row) in DevExpress.
I recommend to not use the out of the box DevExpress GridControl NewItemRow feature. It is evil!

  


My recommendation is to implement your own new row detail in a separate section.

Reason ? 

The row uses multiple mocked bound object through it's life time. Managing state changes is almost impossible.

If your data source is simple then it might work out. But once you need state inside your row, this feature fails.

For example, try adding custom columns with drop down boxes. Now add some custom logic to filter those drop down based on the object's state.
This is where the NewRowItem gets confused. Everytime you click on it, it will create a mock object at first, to bind the drop down boxes to it. Then when you select the first value -from any drop down- it'll recreate the object, and this time trigger the ColumnView.InitNewRow event.

No comments :