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

QueryableDataServiceCollectionView converting models to viewmodels as ItemsSource

1 Answer 48 Views
DataServiceDataSource
This is a migrated thread and some comments may be shown as answers.
Stevo
Top achievements
Rank 1
Stevo asked on 29 Oct 2013, 06:04 PM

Hi,

we would like to switch our DataGrid loading mechanism to use the QueryableDataServiceCollectionView (on top of DataServiceContext), to mainly take advantage of paging, maybe filtering.

However due to some rich functionality in the grid, we are wrapping each 'RowModel' (record) with a 'RowViewModel', supporting the functionality in the grid. So the collection we currently bind the DataGrid.ItemsSource is of type IEnumerable<RowViewModel> rather than IEnumerable<RowModel>. This is done simply by running something like PageViewModel.GridItemsSource = data.Select(m => new RowViewModel(m));

The question is how to achieve the same result with QueryableDataServiceCollectionView? The records loaded will obviously be of type RowModel, however we would like to 'convert' them to 'RowViewModel' instances and bind those to the grid.

Any ideas?

Stevo

 

1 Answer, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 04 Nov 2013, 08:57 AM
Hi Stevo,

Generally, the requirement falls beyond the features of the QDSCV. You can try customizing the Collection by inheriting from it, but this could lead to some unexpected result in a behavioral manner. 

The best way to handle such situations, is to expose the data yourself as ViewModels, and give those ViewModels as an ItemsSource to the GridView.

Hope this helps! 

Regards,
Nik
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
DataServiceDataSource
Asked by
Stevo
Top achievements
Rank 1
Answers by
Nick
Telerik team
Share this question
or