I have prepared a sample project with the Silverlight 4 version of RadGridView released yesterday. The sample project was created with Visual Studio 2010, WCF RIA Services RC 2 for Visual Studio 2010, and ADO.NET Entity Framework (.NET 4). I have decided to use the SalesOrderHeader and SalesOrderDetails tables from the Adventure Works Database, because they provide the perfect one-to-many relationship:
I will not go over the steps for creating the ADO.NET Entity Data Model and the Domain Service Class. In case you are not familiar with them, you should start with Brad Abrams’ series of blog posts and read this blog after that.
To enable the master-details relationship we need to modify two things. First of all we need to include the automatic retrieval of the child entities in the domain service class. We do this by using the Include method:
Next, we need to add the Include attribute to the metadata class:
This should be enough. Now let’s define the RadGridView and a RadDataPager on the client. I have used the Row Details feature of RadGridView. In case you are not familiar with it, you should definitely check this blog out.
As you can see, the details grid has its ItemsSource bound to SalesOrderDetails. Since each SalesOrderHeader has such a property, our details grid will display its contents. As simple as that. I have also added a GridViewToggleRowDetailsColumn for more convenience.
Here is the result:
Here is the full source code of the project.
Subscribe to be the first to get our expert-written articles and tutorials for developers!
All fields are required