User (Old forums)MemberFebruary 15, 2008 at 10:13 pmPost count: 23064
I’ve looked around the docs to see if there is any recommended implementation or support for computed columns in DataGridControl, but haven’t found what I’m looking for yet.
By computed column, I simply mean columns whose value on every row is dependent on the other column values for that row; or a column whose value on each row is computed/determined by some context savvy user supplied function.
For example: a grid with columns A, B and C where C = A+B.
This would be different from a StatFunction because C is computed for each row instead of an entire group.
All input appreciated!
Imported from legacy forums. Posted by Richard (had 4036 views)Xceed SupportMemberFebruary 16, 2008 at 8:08 amPost count: 5658
Built-in? No. But if you had an object where A, B, and A+B (C) were exposed and you had a collection of that object to which the DataGridCollectionView is bound, then it should work fine. You may need to implement INotifyPropertyChanged if you want modifications made to the properties to be updated 🙂
Imported from legacy forums. Posted by Jenny [Xceed] (had 233 views)User (Old forums)MemberFebruary 16, 2008 at 4:56 pmPost count: 23064
Thanks Jenny, that makes sense, thanks for the response.
Perhaps the design team would consider the following suggestion for a future version…
It would be nice if there was the ability to have a “computed/user determined value” column that did not require any modification to the collection that is bound to the grid.
Maybe a computed column type could be added for optional inclusion in grid column definitions. This special column type would allowing binding to a SetValue and GetValue function that would receive the current data row and index as it’s input and in the case of GetValue, return an object of the type specified. I’d guess most users only require read-only computed columns and hence only the GetValue function would be defined.
Thanks for considering the suggestion.
Imported from legacy forums. Posted by Richard (had 564 views)User (Old forums)MemberFebruary 19, 2008 at 12:03 amPost count: 23064
It seems like ValueConverter + MultiBinding seem to help on this already… doesn’t it? You can use it to add computed columns easily.
Imported from legacy forums. Posted by nat (had 756 views)User (Old forums)MemberFebruary 19, 2008 at 9:38 pmPost count: 23064
Thanks for the suggestion, that’s a great idea.
But doesn’t the Xceed DataGrid require you to define a Column that binds to an actual property in your DataSource?
In my case my underlaying data object is not .NET DataTable, so to add a “placeholder” computed column I’ve got to either a. update my object model with a “dummy” property or b. introduce a new layer for this purpose.
Ideally I’d like to see support in the Xceed DataGrid for the concept of adding a new column that is bound to some automatically created repository or to another object you specify or manage abstractly by handling calls to SetComputedValue(CurrentItem,Column) In other words a column in the Xceed DataGrid or probably more appropriately the DataGridCollectionView that can be bound to something besides my ItemsSource.
It “feels” messy even describing it so there is probably a better pattern for doing what I want.
If we can already do something like this I’m not aware of how to and would appreciate all insights.
Imported from legacy forums. Posted by Richard (had 528 views)User (Old forums)MemberFebruary 19, 2008 at 9:49 pmPost count: 23064
I think I’m making this too complicated.
Are you suggesting that a MultiBinding on the Column DisplayMemberBinding with the appropriate ValueConverter is the way to go?
I’ll have to try that.
Imported from legacy forums. Posted by Richard (had 5096 views)
- You must be logged in to reply to this topic.