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

[Solved] Problem with the QueryableCollectionView

2 Answers 208 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jürgen
Top achievements
Rank 1
Jürgen asked on 27 Jul 2011, 02:50 PM
Hi @all,

I need serverside paging and sorting with the GridView, so I use a QueryableCollectionView and the CollectionChanged Event to reload the data from the server if the user sorts or uses the pager. MVVM is very implortant, so I don't want to have any code in the code behind.

I extedet the GridView, I added a ICommand (as a DependencyProperty) to reload the data. That works really fine.

The only problem I have is, that after sorting and paging the Grid, the new data (coming from the server) are ignored by the QueryableCollectionView.
 
If I debug the code I see the new data, in the incomming collection, but the data inside the QueryableCollectionView ar never updated.
If I create a new QueryableCollectionView after the new data comes in, the sorting marker and the pager is in the wrong state.
If I call Refresh() on the QueryableCollectionView after the new data comes in, I get an endless loop.

Do you have any solution to solve that problem? many Thanks :-)

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 27 Jul 2011, 02:53 PM
Hello Jürgen,

 What kind of services you are using in your scenario? In case of WCF RIA services it will be better to use our QueryableDomainServiceCollectionView.

All the best,
Vlad
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Jürgen
Top achievements
Rank 1
answered on 27 Jul 2011, 03:56 PM
Hi Vlad,

many thanks for your answer :-)

I have a plain and simple WCF Service. But I Think the service is not important, because I don't bind the service diretly. The Service works very well, only the new data won't be used and rebound.
The WCF-Service loads a nested Dictionary, because we need a dynamic data structure. In Silverlight we create dynamc types at runtime and feed the GridView with a ObservableCollection auf that types. That works great.

Hier is some Code we use in the exended GriedView:

private void SetDataToGridView(Recordset recordset)
{
    if (recordset == null)
    {
        return;
    }
 
    DataSource = recordset.InternalView;
 
    if (ItemsSource == null)
    {
        ItemsSource = CreateCollectionView(recordset);
        SetupCollectionView(recordset);
    }
    else
    {
        SetupCollectionView(recordset);
    }
}
 
private ExtendedQueryableCollectionView _collectionView;
private int _pagesize = 20;
 
private QueryableCollectionView CreateCollectionView(Recordset recordset)
{
    return new ExtendedQueryableCollectionView(DataSource);
}
 
private void SetupCollectionView(Recordset recordset)
{
    _collectionView.PageSize = _pagesize;
    _collectionView.SetTotalItemsCount(recordset.TotalRowCount);
    _collectionView.CollectionChanged += CollectionChanged;
}
 
private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
    ((QueryableCollectionView)sender).CollectionChanged -= CollectionChanged;
    ReloadData();
}

 

The ExtendedQueryableCollectionView is a dirived class from QueryableCollectionView to manipulate the TotalItemsCount property
The Recordset is our container object, which includes column information, the nested Dictionary from the WCF-Service and the ObservableCollection with our dynamic types
(A teammate of mine, got this solutions from you guys ;-) But the solution doesn't work anymore after i botch something in the code to implement TwoWay binding)

Tags
GridView
Asked by
Jürgen
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Jürgen
Top achievements
Rank 1
Share this question
or