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

Accessing the filtered collection after applying filter and sorting to the WPF radgrid

3 Answers 154 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mausami
Top achievements
Rank 1
Mausami asked on 03 May 2011, 09:58 AM
Hi Sir/Madam,

I am using WPF rad grid (WPFToolkit - Version : 3.5.40128.1).

I want to retrieve the collection of items that is bound to the radgrid after I apply filter and sorting to rad grid.

Radgrid1.ItemSource gives the entire collection whereas Radgrid1.Items gives the collection that is bound to the current page of rad grid but I am not able to find the way to get the entire collection that is bound to the grid after filter.

Awaiting your reply.

Thanks,
Regards,
Mausami

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 03 May 2011, 11:52 AM
Hi Mausami,

I have prepared a sample project for you that represents a possible approach to your case. Please, refer to it and inform us if this solution meets your requirements.

All the best,
Ivan Ivanov
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
0
Mausami
Top achievements
Rank 1
answered on 03 May 2011, 01:20 PM
Hi Ivan ,

I am sorry the solution doesn't seem to meet my requirements. 

I checked RadGridView1.ToHtml(true) returns the rows displayed on only the current page of the radgrid in HTML form.

I need to get the entire filtered collection that is bound to the rad grid after applying filter.

Please could you help me with this.


Thanks,
Regards,
Mausami

0
Mausami
Top achievements
Rank 1
answered on 04 May 2011, 09:31 AM
Hi Ivan,

I got the way to export of exporting paged data in WPF rad grid through one of the demos published by Telerik.
I needed the filtered collection for export to excel functionality.

 

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)

             {

                 int originalPageSize = dataPager.PageSize;

                 int originalPageIndex = dataPager.PageIndex;

                 using (Stream stream = dialog.OpenFile())

                 {     

                      dataPager.PageSize = 0;

                      GridViewExportOptions exportOptions = new GridViewExportOptions();

                      exportOptions.Format = format;

                      exportOptions.ShowColumnFooters = true;

                      exportOptions.ShowColumnHeaders = true;

                      exportOptions.ShowGroupFooters = true;

                      exportOptions.Items = (IEnumerable) dataPager.PagedSource;

   

                     RadGridView1.Export(stream, exportOptions);

                 }

                 dataPager.PageSize = originalPageSize;

                 dataPager.PageIndex = originalPageIndex;

             }

         }

 



Thanks,
Regards,
Mausami
Tags
GridView
Asked by
Mausami
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Mausami
Top achievements
Rank 1
Share this question
or