Telerik blogs

ddsam happy to announce that we have added a new data control to our Silverlight portfolio with one of our latest internal builds. The control will have its official premiere with the upcoming 2010 Q3 Service Pack 1, which is expected in early January. With the release of this service pack you will get access to all of RadDomainDataSource online examples. Since the first version of RadDomainDataSource is now 100% feature complete and has already passed QA, we have decided that we might as well share it with you as a small Christmas present.

RadDomainDataSource is a Silverlight control that provides the missing link between Telerik Data Controls and WCF RIA Services. Make sure that you are Understanding the WCF in ‘WCF RIA Services’ before you read on.Architecture

Up until now, controls like RadGridView, RadDataPager and RadDataFilter did their job solely on the client. You had to write tons of extra code if you wanted to transfer these operations on the server by using the stock DomainDataSource control. Furthermore, things like composite filtering were simply impossible to do with the default DomainDataSource. Now all you need to do is simply bind a Telerik data control to RadDomainDataSource and it will automatically do its job on the server.

When you create a new RIA-enabled Web Application a domain context class is automatically generated in the client project. This domain context is the proxy between the client and the domain service. You could always use this domain context directly and call methods on it to interact with the server. But you will have to handle all the data going back and forth yourself. What RadDomainDataSource offers is to do this job for you automatically. The only two things that RadDomainDataSource needs in order to operate are the domain context and the name of the query method on the server. From then on, RadDomainDataSource will manage all your queries and the data that the server returns. Simply bind RadGridView to RadDomainDataSource.DataView property and you are set.RDDS

For those of you who follow the MVVM pattern strictly, we have exposed RadDomainDataSource’s internal view as a public class. It is called QueryableDomainServiceCollectionView<T> and does just what its name suggests – provides a view over a collection of domain service entities. You can use this class directly in your view models. This is the class responsible for all of the heavyweight lifting. In fact, you can think of RadDomainDataSource as just a very thin wrapper over the Queryable Domain Service Collection View which makes it XAML friendly.

Before you ask, I am currently preparing a whole series of blog posts in which I will discuss and explain topics such as:

  • Loading, filtering, sorting, and paging data (there is no real grouping in WCF RIA yet)
  • Editing and submitting data (CRUD)
  • Query parameters and stored procedures
  • Distinct values
  • Load delay
  • RadDataFilter integration
  • RadDomainDataSource in master-detail scenarios
  • RadDomainDataSource in row details scenarios

I will welcome any suggestions for other possible topics that you want me to cover.

I have prepared and attached a very simple project utilizing RadDomainDataSource, RadGridView and RadDataPager. RadDomainDataSource is located in a new assembly called Telerik.Windows.Controls.DomainServices.You can find the licensed version of this assembly in the internal build from the 20th of December. The latest internal build should be available in your Telerik accounts. The project is also using WCF RIA Services V1.0 SP1 Beta. Here is everything that it takes to bind a grid and a pager to the domain data source:

  1. <telerik:RadDomainDataSource
  2.     x:Name="customersDataSource"
  3.     AutoLoad="True" QueryName="GetCustomers"
  4.     PageSize="10"
  5.     LoadingData="OnCustomersDataSourceLoadingData"
  6.     LoadedData="OnCustomersDataSourceLoadedData">
  7.     <telerik:RadDomainDataSource.DomainContext>
  8.         <e:NorthwindDomainContext />
  9.     </telerik:RadDomainDataSource.DomainContext>
  10. </telerik:RadDomainDataSource>
  12. <telerik:RadBusyIndicator
  13.     IsBusy="{Binding IsBusy, ElementName=customersDataSource}">
  14.     <telerik:RadGridView
  15.         x:Name="radGridView"
  16.         Grid.Row="0"
  17.         ItemsSource="{Binding DataView, ElementName=customersDataSource}"
  18.         DistinctValuesLoading="OnRadGridViewDistinctValuesLoading"
  19.         ShowGroupPanel="False"
  20.         IsReadOnly="True"/>
  21. </telerik:RadBusyIndicator>
  22. <telerik:RadDataPager
  23.     x:Name="radDataPager"
  24.     Grid.Row="1"
  25.     Source="{Binding DataView, ElementName=customersDataSource}"
  26.     DisplayMode="All"
  27.     IsTotalItemCountFixed="True"/>

You can use this sample project to play around with the new control and let me know what you think. You can either post a comment here or send me a message on twitter.

Download Sample Project

Merry Christmas and a Happy New Year to you and your families!

About the Author

Rossen Hristov

 is Senior Software Developer in Telerik XAML Team


Comments are disabled in preview mode.