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

VirtualQueryableCollectionView and Export

6 Answers 158 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dario Concilio
Top achievements
Rank 2
Dario Concilio asked on 19 Apr 2016, 11:36 AM

Hi,

I would export by datagrid and I populated it by VirtualQueryableCollectionView collection.

Example:

I have a lot of row (ex. 1000)

I used a pagesize 10

I try to export and I see the lines already loaded only.

How can I load (in this case) all rows?

Note: User can filter any columns.

6 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 21 Apr 2016, 10:22 AM
Hello Potito,

If you want to be able to export all items you must ensure that they are loaded.

For example, if you ViewModel has a VirtualQueryableCollectionView called View, you can do this in the following way:

var viewModel = this.RadGridView.DataContext as ViewModel;
viewModel.View.LoadSize = this.RadGridView.Items.TotalItemCount;

Bear in mind that this will lead to poor performance when dealing with large amounts of data.

What I can suggest is to use a QueryableCollectionView or other collection that has all the items available.

I hope you find this information helpful.

Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Dario Concilio
Top achievements
Rank 2
answered on 22 Apr 2016, 07:23 AM

It's clear, I try to explain the events in sequence:

  1. open my usercontrol that contains RadGridView, its itemsource is in binding with VirtualQueryableCollectionView (without filter it shows 1000 rows).
  2. Apply some filter, result it shows me a subset of 100 rows. But with pagesize = 10, it shows me a little subset of data (this only rows is loaded)
  3. This approach allows to show quickly my data, when I scrolldown I see more rows, actually I see 20 rows (first 20 items loaded)
  4. At a certain point, I would like to export my data based on filter that I set, but I have seen 20 rows of 100 total and 100 rows are the result of the filters set.
  5. OK! Now I press button to export......and now? I should be able to load all 100 rows before exporting, but only the 100 because I have to take account of the filters
0
Accepted
Dilyan Traykov
Telerik team
answered on 26 Apr 2016, 10:36 AM
Hello Potito,

Could you please confirm that you meant PageSize and not LoadSize in step 2 of your last reply as this statement contradicts to the 3rd step you've described as you will not be able to scroll to the next 10 items if there was a RadDataPager involved?

If that is not the case, and you did mean LoadSize, the method, provided in my last reply should work correctly. To better demonstrate this, I'm attaching a sample project for you to have a look at. I've tested it with the steps you've described in your last reply and it seems to behave as expected. Please correct me if I'm wrong.

If you are, however, using a RadDataPager, I recommend having a look at the "Export Paged Data Excel" example from our SDK Samples Browser.

I hope you find this helpful.

Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Dario Concilio
Top achievements
Rank 2
answered on 27 Apr 2016, 07:56 AM

I'm sorry, I've mistake a property.

This is my code

var view = new VirtualQueryableCollectionView((List<Customer>) response.Info) { LoadSize = 10 };
Customers = view;

0
Dilyan Traykov
Telerik team
answered on 27 Apr 2016, 10:30 AM
Hello Potito,

Did you have a chance to take a look at the sample project I've provided in my last reply? If so, could you let me know if the demonstrated approach is applicable to your scenario?

Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Dario Concilio
Top achievements
Rank 2
answered on 27 Apr 2016, 11:35 AM

Perfect!

Thank you very much.

Tags
GridView
Asked by
Dario Concilio
Top achievements
Rank 2
Answers by
Dilyan Traykov
Telerik team
Dario Concilio
Top achievements
Rank 2
Share this question
or