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

[Solved] Exporting GridView + WCF RIA Services

1 Answer 88 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chris
Top achievements
Rank 1
Chris asked on 17 Sep 2010, 04:39 PM
Hi,

I have a RadDataPager that is bound in XAML to a WCF RIA Service domain data source and this pager is providing the PagedSource for my GridView.

I want to provide the user with options to export either the current page of grid data or all the grid data to an Excel file via the file save dialog. The issue I have is that when I change the PageSize property of my pager, the RIA service is called to retrieve all the data. As this call happens async there is no way for me to then invoke the file save dialog once the data has been returned, due to the security restrictions in Silverlight.

Due to the size of the data being displayed a pager is required. Does anyone know of way this can be achieved? The below code shows what I am trying to do:

var saveFileDialog = new SaveFileDialog
            {
                DefaultExt = extension,
                Filter = string.Format("{0} files (*.{1})|*.{1}|All files (*.*)|*.*", format, extension),
                FilterIndex = 1
            };
  
            if (saveFileDialog.ShowDialog() == true)
            {
                // Store original pager settings
                int originalPageSize = radDataPager.PageSize;
                int originalPageIndex = radDataPager.PageIndex;
  
                using (Stream fileStream = saveFileDialog.OpenFile())
                {
                    if (allData)
                        radDataPager.PageSize = 0;
  
                    this.InstanceGrid.Export(fileStream, new GridViewExportOptions
                    {
                        Format = format1,
                        ShowColumnFooters = true,
                        ShowColumnHeaders = true,
                        ShowGroupFooters = true
                    });
                }
  
                // Restore pager settings
                radDataPager.PageSize = originalPageSize;
                radDataPager.PageIndex = originalPageIndex;
            }

Regards,
Chris

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 22 Sep 2010, 02:41 PM
Hi Chris,

I suggest the following: when the user chooses to export all the data - open a new window (e.g. RadWindow) showing the RadGridView with all the data loaded (so you do not use the data pager here) and a button export. Clicking on it should export all the data.

All the best,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Chris
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or