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

DataGrid NHibernate VirtualQueryCollectionView Lazyload Binding Issue

1 Answer 123 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 02 Oct 2014, 02:20 PM
Hi,

I have an issue with the RadGridView when used with NHibernate and Lazy loading.

When the page initially loads the gridview appears empty, but if I scroll data appears; this is aldo tru for paging with the RadDataPager, the first page appears empty but if you move to the second page then back, the data can be seen.

I am using the MVVM pattern and exposing an instance of VirtualQueryCollectionView to the view; if I put a break point on the property, I can see it being hit when the grid binds to the ViewModel. Looking inside the instance of the VirtualQueryCollection, I can see my data in the QueryableSourceCollection property, but the results view shows an IEnumerable filled with nulls.

A simplified view of my code would be something like:

View

<telerik:RadGridView x:Name="Grid" ItemsSource="{Binding MyDataCollection}">

ViewModel

protected MyViewModel(MyDataRepository repository)
{
   Repository = repository;
   GetMyData()
}
 
public VirtualQueryableCollectionView MyDataCollection { get; set; }
 
private void GetMyData()
{
   MyDataCollection= new VirtualQueryableCollectionView(Repository.GetMyData() {LoadSize = 50, VirtualItemCount = 4000})
}

Repository

public IQueryable<MyData> GetMyData ()
{
   var session = Session.SessionFactory.OpenSession()
   return session.Query<MyData>()
                          .Where(a => Property1.Contains(a.Value));
 
}


Any advice would be more than welcome, however I am stuck with NHibernate and must use lazy loading because of the amount of data.

Thanks In advance.


Paul.

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 07 Oct 2014, 11:35 AM
Hi Paul,

Do you use the virtual collection along with RadDataPager? If so, then the reason for this problem would be that you are using them together. The RadDataPager and the VirtualQueryableCollectionView are two different alternatives to solving the same problem. They were never meant or designed to work with each other, since it does not make sense.

The idea of the VirtualQueryableCollectionView is to load only the items needed at the moment, i.e. those that are visible. All the items that are not in the view port are not available till you scroll to them.  In that case the user moves up and down and requests different parts of the data - there is your "paging".  

When using the data pager it shows only one page with the loaded data and it is not aware that there are other items to be loaded. You can check this blog post describing the purpose of RadDataPager. So you have to use either paging or data virtualization, since there is no such architectural concept as using them in combination.

If not, then you say you can observe the same problem no matter if you use any of the approaches. I tested on our WPF Demos and I could not notice any problem. In that case, may I ask you to isolate the issue in a demo project and send it to us? You can also take a look at this blog post for a reference on how to isolate an issue. That way we can check it locally and we will be able to advise further.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Paul
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or