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

VirtualQueryableCollectionView with Devforce

10 Answers 113 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Fredrik
Top achievements
Rank 2
Fredrik asked on 04 Apr 2013, 06:46 AM
Hello, i have problems with VirtualQueryableCollectionView in my gridview.
i have a query that has around 1500 records and is implemented  like below.
But its not behaving correctly:
_Data.ItemsLoading triggers continuesly until it has gone throgh all the records.
i suspect this due to Data.load never gets triggerd because before the
await _bcVaresalg.EntityManager.ExecuteQueryAsync<db_VareSalg>(qry) is finished the VirtualQueryableCollection finds out that there is no data and runs another Itemsloading, and aslong as this is going; Data.Load(startIndex, result) never gets called until it has gone through all the records


any suggestions?
ps. since i work with devforce IEntityQuery i dont have access to completed event on the ExecuteQueryAsync
VirtualQueryableCollectionView<db_VareSalg> _Data;
 
public VirtualQueryableCollectionView<db_VareSalg> Data
{
    get
    {
        if (_Data == null)
        {
            _Data = new VirtualQueryableCollectionView<db_VareSalg>() { LoadSize = 20 };
 
            Deployment.Current.Dispatcher.InvokeAsync(
            async () =>
            {
 
                int result = await _bcVaresalg.EntityManager.db_VareSalg
                .Where(x => x.n_FakturaLinje.Count == 0)
                .Where(x => x.p_Sum != 0).AsScalarAsync().Count();
                _Data.VirtualItemCount = result;
 
 
                _Data.ItemsLoading += async (s, e) =>
                {
                    await LoadData(e.StartIndex, e.ItemCount);
 
                };
 
                await LoadData(0, _Data.LoadSize);
 
 
 
            });
 
 
        }
 
        return _Data;
 
 
 
    }
}
async Task LoadData(int startIndex, int itemCount)
{
    try
    {
        IEntityQuery<db_VareSalg> qry = (EntityQuery<db_VareSalg>)_bcVaresalg.EntityManager.db_VareSalg
                .Where(x => x.n_FakturaLinje.Count == 0)
                .Where(x => x.p_Sum != 0)
                .OrderBy(x => x.p_Dato)
                .Skip(startIndex).Take(itemCount);
         
        var result = await _bcVaresalg.EntityManager.ExecuteQueryAsync<db_VareSalg>(qry);
        Data.Load(startIndex, result);
 
 
    }
    catch (Exception ex)
    {
        ShowMessage(MessageSeverity.FatalError, ex.Message);
    }
 
}

10 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 09 Apr 2013, 07:39 AM
Hello,

You can take a look at this blog post which could give an idea how to deal with such scenarios.

Regards,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Fredrik
Top achievements
Rank 2
answered on 09 Apr 2013, 08:44 AM
I have it more or less the same as the blogg except i use deforce ExecuteQueryAsync insted of DomainContext.load.
but these basicly just do the same.

regardless I am still stuck in a loop on itemsloading until all the records have been loaded...


VirtualQueryableCollectionView<
db_VareSalg> _Data;
public VirtualQueryableCollectionView<db_VareSalg> Data
{
    get
    {
        if (_Data == null)
        {
            _Data = new VirtualQueryableCollectionView<db_VareSalg>() { LoadSize = 20 };
            Deployment.Current.Dispatcher.InvokeAsync(
            async () =>
            {
                    int result = await _bcVaresalg.EntityManager.db_VareSalg
                    .Where(x => x.n_FakturaLinje.Count == 0)
                    .Where(x => x.p_Sum != 0).AsScalarAsync().Count();
                    _Data.VirtualItemCount = result;
          
                    Data.ItemsLoading += async (s, e) =>
                    {
                        IEntityQuery<db_VareSalg> queryToLoad = (EntityQuery<db_VareSalg>)_bcVaresalg.EntityManager.db_VareSalg
                                                                .Where(x => x.n_FakturaLinje.Count == 0)
                                                                .Where(x => x.p_Sum != 0)
                                                                .OrderBy(x => x.p_Dato)
                                                                .Skip(e.StartIndex).Take(e.ItemCount);
                        Data.Load(e.StartIndex, await _bcVaresalg.EntityManager.ExecuteQueryAsync<db_VareSalg>(queryToLoad));
                    };
        });
        }
        return _Data;
    }
}
0
Nedyalko Nikolov
Telerik team
answered on 12 Apr 2013, 10:48 AM
Hello,

I've tried to simulate your issue unfortunately to no avail. I'm attaching my sample application for a reference.
I've attached a SQL profiler and a new query is executed when new items should be loaded (everything works as expected). Could you please try to reproduce your case with this project?

One possible reason for such behavior could be if RadGridView is placed inside a container which measures its children with infinity (like StackPanel for example), then RadGridView will try to create row for every item and will iterate all items.

Greetings,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Fredrik
Top achievements
Rank 2
answered on 15 Apr 2013, 08:28 AM
Hello, i dont what solved it but i followed your example and suddenly it works
great =)

i have however a problem with the filtering & grouping

the filtering by input works, but only the checbox for everyone and null comes up.
i also have trouble getting the drag column to group function to work properly

any suggestions?

0
Nedyalko Nikolov
Telerik team
answered on 18 Apr 2013, 10:28 AM
Hello,

Generally VirtualQueryableCollectionView does not support sorting, filtering and grouping when used via ItemsLoading event. In order to perform such operations VQCV needs all the data. You could use ItemsLoading event in case of sorting and filtering (you should manually sort and filter your data using the information inside VQCV.Sort(Filter)Descriptors. However with the grouping case you can take a look at this blog post.

Regards,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Fredrik
Top achievements
Rank 2
answered on 19 Apr 2013, 12:26 PM
Hello regarding the grouping part:
my following code.
private VirtualQueryableCollectionView<db_VareSalg> _data;
public VirtualQueryableCollectionView<db_VareSalg> Data
{
    get
    {
        if (_data == null)
        {
            this._data = new VirtualQueryableCollectionView<db_VareSalg>() { LoadSize = 20 };
        }
        return this._data;
    }
}
public async Task InitiateVirtualQuery() {
              
                IEntityQuery<db_VareSalg> queryToLoad = (EntityQuery<db_VareSalg>)StoredQuery;
                Loading = true;
                this._data.VirtualItemCount = await queryToLoad.AsScalarAsync().Count();
                Loading = false;
      
                _data.FilterDescriptors.CollectionChanged += async (s, e) =>
                {
                    IEntityQuery<db_VareSalg> fquery = (EntityQuery<db_VareSalg>)StoredQuery;
                    fquery = (EntityQuery<db_VareSalg>)fquery.Where(_data.FilterDescriptors);
                    Loading = true;
                    _data.VirtualItemCount = await this._bcVaresalg.GetCount(fquery);
                    Loading = false;
                };
          
                this._data.ItemsLoading += async (s, e) =>
                {
                    await this.LoadData(e.StartIndex, e.ItemCount);
                };
                await this.LoadData(0, this._data.LoadSize);
}
private async Task LoadData(int startIndex, int itemCount)
{
    try
    {
          
        IEntityQuery<db_VareSalg> queryToLoad = (EntityQuery<db_VareSalg>)StoredQuery;
        queryToLoad = (EntityQuery<db_VareSalg>)queryToLoad.Where(Data.FilterDescriptors);
        queryToLoad = (EntityQuery<db_VareSalg>)queryToLoad.Sort(Data.SortDescriptors);
        queryToLoad = (EntityQuery<db_VareSalg>)queryToLoad.GroupBy(Data.GroupDescriptors);
        queryToLoad = queryToLoad.OrderBy(x => x.p_Dato).Skip(startIndex).Take(itemCount);
        Loading = true;
        var result = await this._bcVaresalg.EntityManager.ExecuteQueryAsync(queryToLoad);
        Loading = false;
        this.Data.Load(startIndex, result);
    }
    catch (Exception e)
    {
        ShowMessage(MessageSeverity.RecoverableError, GetResourceString("view_varesaltilfakturering_message_genfakturafeil"), e.Message);
    }
}

I started to try implement something like this:
to fetch all records and group by it.
but cant get it to work properly. it start grouping by one entry but then stops.
_data.GroupDescriptors.CollectionChanged += async (s, e) =>
{
    var result = await this._bcVaresalg.EntityManager.ExecuteQueryAsync(queryToLoad);
    _data.VirtualItemCount = result.Count();
    Data.Load(0, result);
  
};

any suggestions on how to implement this in a mvvm perspective would be highly appreciated

0
Nedyalko Nikolov
Telerik team
answered on 24 Apr 2013, 06:31 AM
Hi,

If you plan to use sorting, filtering and grouping features of RadGridView there is no need to use VirtualQueryableCollectionView as ItemsSource. All you have to do is to give the IQueryable items source and let RadGridView to do its job. RadGridView has full support for IQueryable and every operation will be executed on the server, so you should not worry about the performance. VirtualQueryableCollectionView cannot perform any data shape operations with only a subset of the data, therefore VQCV support such scenarios partially (when VQCV is created with an IQueryable source, when used with ItemsLoading event these scenarios does not work).

Greetings,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Fredrik
Top achievements
Rank 2
answered on 26 Apr 2013, 06:11 AM
Hello, can you provide an example of use of IQueryable for my scenario.
0
Fredrik
Top achievements
Rank 2
answered on 26 Apr 2013, 10:35 AM
My main problem is basicly that my datasource is to large to be retrieved in one fetch, it boils down to memory problems.

0
Nedyalko Nikolov
Telerik team
answered on 30 Apr 2013, 02:34 PM
Hi,

I'm not familiar with Idea Blade data sources, but for dealing with large data in Silverlight I could recommend using RadDomainDataSource control combined with DataPager.

Regards,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Fredrik
Top achievements
Rank 2
Answers by
Nedyalko Nikolov
Telerik team
Fredrik
Top achievements
Rank 2
Share this question
or