QueryableDataServiceCollectionView converting models to viewmodels as ItemsSource

2 posts, 0 answers
  1. Stevo
    Stevo avatar
    25 posts
    Member since:
    Jun 2013

    Posted 29 Oct 2013 Link to this post

    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

     

  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 04 Nov 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top