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

[Solved] Grid View Paged Records Export Pdf

3 Answers 133 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.
Wang
Top achievements
Rank 1
Wang asked on 07 Mar 2013, 08:56 AM
Hi Guys,
    At this moment , the version of  'Telerik.Windows.Controls' is 2011.2.712.1040.
    
    In my project , the RadGridView have displayed some large records. according to page ui design , these records have been paged by using RadDataPager. when i have exported records for csv document , but this exported csv document do not have all records , only have this current page records.

    Why this export function can not export all records ? how to solve it ?

    I am in urgent need for your helps. 
    thanks.

    please see the export button function code snippet as below :
    

private void Button_Click(object sender, System.Windows.RoutedEventArgs e)

        {

            string extension = "";

            ExportFormat format = ExportFormat.Html;

 

            RadComboBoxItem comboItem = ComboBox1.SelectedItem as RadComboBoxItem;

            string selectedItem = comboItem.Content.ToString();

 

                                                switch (selectedItem)

                                                {

                                                                case "Excel": extension = "xls";

                                                                                format = ExportFormat.Html;

                                                                                break;

                                                                case "ExcelML": extension = "xml";

                                                                                format = ExportFormat.ExcelML;

                                                                                break;

                                                                case "Word": extension = "doc";

                                                                                format = ExportFormat.Html;

                                                                                break;

                                                                case "Csv": extension = "csv";

                                                                                format = ExportFormat.Csv;

                                                                                break;

                                                }                        

 

            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;

 

                    RadGridView1.Export(stream, exportOptions);

                }

            }

        }

3 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 07 Mar 2013, 09:10 AM
Hello Wang,

Indeed, in paged scenario, RadGridView knows about the items in the current page only . 

So, you can try the following approach:

  1. When you want to export, set the PageSize to 0. This will disable paging and display all of the data.
  2. Then Export.
  3. After that, return the PageSize to whatever it was.

I hope this helps.

All the best,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Wang
Top achievements
Rank 1
answered on 07 Mar 2013, 09:11 AM
Hi ,
    I am sorry.

    that title should be 'Grid View Paged Records Export Csv'. 

    thanks.
0
Tobias
Top achievements
Rank 1
answered on 06 May 2013, 06:32 AM
Hi,
sorry but your step-step tutorial doesnt work for me.

1. i save my GridPager.PageSize in a helper variable
2. I set the PageSize to 0
3. I do my export (all pages => check)
3. I set the Pagesize to the old value.

Now, I just see in my Grid "0 of 1" Page instead of "1 of 1500".

I thought, I have to fire the SizeChanged- Event but this is just a variable to write my own event handler?

Thanks for your help!

- Tobias
Tags
GridView
Asked by
Wang
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Wang
Top achievements
Rank 1
Tobias
Top achievements
Rank 1
Share this question
or