This is a migrated thread and some comments may be shown as answers.
Export a VirtualQueryableCollectionView does only export already loaded items
10 Answers 65 Views
This is a migrated thread and some comments may be shown as answers.
Jonx
Top achievements
Rank 2
Jonx asked on 17 Feb 2011, 04:09 PM
Hello,
I want to export all the items from my collection but only those already loaded get exported.
How can I export the full list of items?
Do I need to use something like a RadDomainDataSource in which I tranfert the selectors from the current virtual view?
How should I do to export all my data?
Any exemple?
Thanks a lot in advance,
John.

10 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 17 Feb 2011, 04:19 PM
Hello,

 You need to force load of all data if you want to export all of them - download the data and load them using the Load() method of the collection. 

Greetings,
Vlad
the Telerik team
0
Jonx
Top achievements
Rank 2
answered on 17 Feb 2011, 04:33 PM
Hello Vlad,
Thank you for your help.

What if the collection is pretty big?
Will the virtual collection still load the items by page?
How do I force the loading of all the items?
Just call Load() ? And I guess this will take some time...
Do I have to pool somehow the view and wait until it has loaded all the items?
How do I know alll the items have been loaded?

I'm a bit lost...
Would you have a sample handy? That would help a lot...

Thanks a lot...
John.
0
Vlad
Telerik team
answered on 17 Feb 2011, 04:43 PM
Hello,

 How the collection will load data in your case? Are you using ItemsLoading? Are you loading the data from a service? 

All the best,
Vlad
the Telerik team
0
Jonx
Top achievements
Rank 2
answered on 17 Feb 2011, 04:56 PM
I'm loading the view like that:
private SoContext context = new SoContext();
 
public History()
{
    InitializeComponent();
 
    //DataContext = new VirtualHistoryDatacontext();
 
    var query = context.GetBeneficiaryOrderLinesHistoQuery().OrderBy(o => o.OdlID);
 
    var view = new VirtualQueryableCollectionView() { LoadSize = 10, VirtualItemCount = 100 };
    view.ItemsLoading += (s, e) =>
    {
        var queryToLoad = query.IncludeTotalCount(true).Sort(view.SortDescriptors).Where(view.FilterDescriptors).Skip(e.StartIndex).Take(e.ItemCount);
 
        context.Load<CustomerPresentationModel>(queryToLoad).Completed += (sender, args) =>
        {
            var lo = (LoadOperation)sender;
            if (lo.TotalEntityCount != -1 && lo.TotalEntityCount != view.VirtualItemCount)
            {
                view.VirtualItemCount = lo.TotalEntityCount;
            }
 
            view.Load(e.StartIndex, lo.Entities);
        };
    };
     
    DataContext = view;
}

And then export like that:
SaveFileDialog dialog = new SaveFileDialog();
dialog.DefaultExt = extension;
dialog.Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, selectedItem);
dialog.FilterIndex = 1;
 
if (dialog.ShowDialog() == true)
{
    using (Stream stream = dialog.OpenFile())
    {
        GridViewExportOptions exportOptions = new GridViewExportOptions();
        exportOptions.Format = format;
        exportOptions.ShowColumnFooters = true;
        exportOptions.ShowColumnHeaders = true;
        exportOptions.ShowGroupFooters = true;
 
        try
        {
            grdHistory.Export(stream, exportOptions);
        }
        catch (Exception ex)
        {
            ErrorWindow error = new ErrorWindow("L'exportation a échoué : ", ex.Message);
            error.Show();
        }
    }
}

Thanks a lot for the fast reply. I really need this...
John.
0
Vlad
Telerik team
answered on 17 Feb 2011, 05:03 PM
Hi,

You can load all data using Load<>() method of your context (SoContext) - indeed you may get communication problems if you have too much data on the server. 

Best wishes,
Vlad
the Telerik team
0
Jonx
Top achievements
Rank 2
answered on 17 Feb 2011, 05:08 PM
Indeed... That's why I used the virtual view...

I have two problems... Load lot's of data and load only those corresponding to the current view selectors (sorting and filters). Can I use those selector as-is to load my context collection?
0
Vlad
Telerik team
answered on 17 Feb 2011, 05:10 PM
Hi,

 Maybe it will be better in this case to export data on the server and download the result using Telerik Reporting.

Regards,
Vlad
the Telerik team
0
Jonx
Top achievements
Rank 2
answered on 17 Feb 2011, 05:16 PM
Ha yeah, I didn't think of that. Why not. Can I let my user sort, filter and group in the report?
I mean let him choose dynamicaly on which column to sort etc?
0
Steve
Telerik team
answered on 22 Feb 2011, 05:35 PM
Hi John,

It depends on your data and its presentation. If you're using the Table/Crosstab item, groups, sorting and filters are a bit more complicated to execute from end user point of view and we do not recommend doing this. The Report Designer does a great deal of work to simplify common tasks, but the underlying code is far from trivial especially when it comes to Crosstab report item, which is not a mere grid of cells and has a very complex internal structure.

Greetings,
Steve
the Telerik team
0
Jonx
Top achievements
Rank 2
answered on 22 Feb 2011, 05:55 PM
Hello Steve,
Thank you for the link and the explanation.
I think I'll try to go that way and we'll see where it goes...
Thanks again,
John.
Asked by
Jonx
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Jonx
Top achievements
Rank 2
Steve
Telerik team
Share this question
or