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

Load on demand - GridView

10 Answers 84 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Balsuyambu
Top achievements
Rank 1
Balsuyambu asked on 11 Sep 2012, 11:14 AM

Hi

We have a requirement to load thousand of records in grid control and tried to implament load on demand using VirtualQueryableCollectionView.

But if i load 5 lak records in my test page and tested with normal loading techniquies as well as VirtualQueryableCollectionView.

both are getting same time to load (4-5 seconds).

Normal way

public UCTSGridTest()

{

    InitializeComponent();

    CollList = Club.GetClubs();

     clubsGrid.ItemsSource = CollList;
}

Using VirtualQueryableCollectionView

  

public UCTSGridTest()

{

    InitializeComponent();

    CollList = Club.GetClubs();

     view = new VirtualQueryableCollectionView() { LoadSize = 10, VirtualItemCount = 500000 };

     DataContext = view;
    view.ItemsLoading += new EventHandler<VirtualQueryableCollectionViewItemsLoadingEventArgs>    (view_ItemsLoading);

}

void view_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)

{

    view.Load(e.StartIndex, CollList.Skip(e.StartIndex).Take(e.ItemCount));

}

 

 

Did i miss anything

 

10 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 11 Sep 2012, 11:58 AM
Hello,

 Yes. You are getting all records in both cases on initial load:

 InitializeComponent();

    CollList = Club.GetClubs();

....

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Balsuyambu
Top achievements
Rank 1
answered on 11 Sep 2012, 12:13 PM
Hi

VirtualQueryableCollectionView is used to load the intial set of records (example 10) on initial page load and loads set of records throuch scroll bar selection.

In this case, it should not load all records into grid.

can you clarify

0
Vlad
Telerik team
answered on 11 Sep 2012, 12:17 PM
Hello,

 You may need to load your records from a database server or service instead in-memory to know what's the difference. 

Greetings,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Balsuyambu
Top achievements
Rank 1
answered on 11 Sep 2012, 12:25 PM
Hi Vlad,

Thanks for your clarifications. I wil do that and update you

Thanks
Balsuyambu
0
Balsuyambu
Top achievements
Rank 1
answered on 13 Sep 2012, 07:48 AM
Hi Vlad,

I got the 5 Lak records from web service and bind to the grid in normal loading techniquies as well as VirtualQueryableCollectionView and find below the code.

BOTH way are getting same time.

Normal way

 void objPlayer_getPlayersCompleted(object sender, wsPlayers.getPlayersCompletedEventArgs e)
{
    clubsGrid.ItemsSource = e.Result;
}

Using VirtualQueryableCollectionView 

ObservableCollection<ToucScreenAppln.wsPlayers.Player> lplayer;
 void objPlayer_getPlayersCompleted(object sender, wsPlayers.getPlayersCompletedEventArgs e)
 {
            lplayer = e.Result;
            view = new VirtualQueryableCollectionView() { LoadSize = 10, VirtualItemCount = e.Result.Count };
            DataContext = view;
            view.ItemsLoading += new EventHandler<VirtualQueryableCollectionViewItemsLoadingEventArgs>(view_ItemsLoading);
}

 void view_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
{
            view.Load(e.StartIndex, lplayer.Skip(e.StartIndex).Take(e.ItemCount));
}

Please let me know the implementation of VirtualQueryableCollectionView approach is correct ?
0
Vlad
Telerik team
answered on 13 Sep 2012, 07:52 AM
Hello,

 Are you loading your data on portions using ItemsLoading event? I don't see any call to your service from ItemsLoading.

Greetings,
Vlad
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Balsuyambu
Top achievements
Rank 1
answered on 13 Sep 2012, 08:36 AM
Hi

I got the object from webservice in objPlayer_getPlayersCompleted method and convert this object into ObservableCollection object and bind ObservableCollection object into item loading event

Please find below the highlighted lines

ObservableCollection<ToucScreenAppln.wsPlayers.Player> lplayer;

void objPlayer_getPlayersCompleted(object sender, wsPlayers.getPlayersCompletedEventArgs e)
 {
            lplayer = e.Result;
            view = new VirtualQueryableCollectionView() { LoadSize = 10, VirtualItemCount = e.Result.Count };
            DataContext = view;
            view.ItemsLoading += new EventHandler<VirtualQueryableCollectionViewItemsLoadingEventArgs>(view_ItemsLoading);
}

 void view_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
{
            view.Load(e.StartIndex, lplayer.Skip(e.StartIndex).Take(e.ItemCount));
}

is this correct approach?
0
Vlad
Telerik team
answered on 13 Sep 2012, 08:39 AM
Hi,

 The idea is to call your service with two parameters in ItemsLoading - e.StartIndex and e.ItemCount. In this case you will load only portion of the data not all of it. 

All the best,
Vlad
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Balsuyambu
Top achievements
Rank 1
answered on 13 Sep 2012, 08:47 AM
Hi

Do you mean to say if i want to load 10 rows then service should get the 10 rows of data from item loading event based on start index and item count. 

We can call web service through Async mode then how to call service through item loading event.

if you have any sample project, please attache.

thanks
Balsuyambu s. 
0
Vlad
Telerik team
answered on 13 Sep 2012, 08:56 AM
Hello,

 Yes. You should call the service with the parameters returned from ItemsLoading. Later you can call Load() method of the virtual collection to load your data into the collection. I suggest you to check both our demos an documentation for more info. You can check also my blog posts:

http://blogs.telerik.com/vladimirenchev/posts/11-04-18/telerik-data-virtualization-wcf-ria-services-and-visual-studio-async-ctp.aspx

http://blogs.telerik.com/vladimirenchev/posts/10-12-09/server-sorting-and-filtering-with-wcf-ria-services-and-telerik-data-virtualization-for-silverlight.aspx

http://blogs.telerik.com/vladimirenchev/posts/10-10-20/data-virtualization-for-your-silverlight-and-wpf-applications.aspx 

Kind regards,
Vlad
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

Tags
General Discussions
Asked by
Balsuyambu
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Balsuyambu
Top achievements
Rank 1
Share this question
or