This is a migrated thread and some comments may be shown as answers.

Binding DataGrid with Multiple collections

4 Answers 382 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nikhil Jain
Top achievements
Rank 1
Nikhil Jain asked on 16 Apr 2011, 01:59 PM
Hi

I Want to know how can I bind a single DataGrid with Multiple ObervableCollections with each ObervableCollection having different element Type.

Regards
.

4 Answers, 1 is accepted

Sort by
0
Ivan
Top achievements
Rank 1
answered on 17 May 2011, 11:35 AM
Can we get some sort of answer to this question?

Im having a similiar issue. Here is an example scenario:

I have two database tables, Product and orders. I can easily use a linq query to return the Product table into an observable collection, then bind that to the radgrid. But i want to go further, and join the product and orders table together (join them on the primary and foreign keys) and bind that to the radgrid. This now means im trying to bind the grid to two types (product and orders).  Any help or a code example on how to go about this maintaining mvvm rules. Thanks,
0
Ivan Ivanov
Telerik team
answered on 18 May 2011, 03:11 PM
Hi Ivan,

Please, refer to the attached example and let us know if this approach meets your requirements.

All the best,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ivan
Top achievements
Rank 1
answered on 22 May 2011, 12:09 PM
Thats an excellant example thankyou.

Now, in your example you bind to the query using the itemsource in the code behind file.
What I tried doing however was setting the binding in the xaml file because I want to minimise code in the code behind file.
I managed to do this. But of course now im binding to a method in my ViewModel which requires some sort of return type. This is when I get confused again. So how do we do this? Do I have to make my query output to a observable collection? When I try this I get lots problem, because my collection or list is for only 1 type which is either products or orders. Can you help me with this scenario?


So basically can you modify the example solution that shows binding in the xaml instead of the code behind file?

Thanks, Ivan.



0
Ivan Ivanov
Telerik team
answered on 25 May 2011, 12:04 PM
Hi Ivan,

I have prepared a MVVM implementation of my initial project. Please, refer to it.

All the best,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Nikhil Jain
Top achievements
Rank 1
Answers by
Ivan
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or