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

Get current sorting on a gridview

3 Answers 64 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Edwin
Top achievements
Rank 1
Edwin asked on 03 Oct 2012, 04:00 PM
Hello,

I have serveral gridviews with observable collections as their items sources.  I have a button which does an Excel export on the grids (by getting the item's sources).  I would like the export to match whatever sorting the users applied on the grid.  How can I accomplish this?

Thank you.

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 04 Oct 2012, 07:03 AM
Hello,

 The Export() method will export the data in the same order as you can see them sorted in the GridView. You can check our Exporting WPF demo for an example.

May I ask you to clarify what exactly do you mean by "the export to match whatever sorting the users applied"?

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Edwin
Top achievements
Rank 1
answered on 04 Oct 2012, 03:56 PM
I am not using the Export function of the grid because the solution required the use of OpenXML to generate the Excel file.  What I mean by "the export to match whatever sorting the users applied" is that I want the order of the rows in the Excel file to match the order on the grids once the users have sorted the grid in whatever way they like.  Is there a way to get the sorted collection that is the source data for the grid? or get a list of columns on which the grid is being sorted?
0
Vlad
Telerik team
answered on 05 Oct 2012, 05:26 AM
Hello,

You use the grid Items collection to build your document. This collection will respect sorting, filtering, etc.

All the best,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Edwin
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Edwin
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or