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

Programmatically sort columns(s) before exporting

1 Answer 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JM
Top achievements
Rank 1
JM asked on 11 Aug 2008, 07:50 AM
Good day.

Is there a way to sort column(s) before exporting the grid to Excel? I would like to perform sorting in the ConfigureExport() method of the demo RadGrid Export source.

Thanks in advance.

JM

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 11 Aug 2008, 07:57 AM
Hi JM,

You can use ExcelML export and add the following code to ConfigureExport() method:

        public void ConfigureExport()
        {
            GridSortExpression exp = new GridSortExpression();
            exp.FieldName = "ContactName";
            exp.SortOrder = GridSortOrder.Descending;

            RadGrid1.MasterTableView.SortExpressions.AddSortExpression(exp);

            RadGrid1.ExportSettings.ExportOnlyData = CheckBox1.Checked;
            RadGrid1.ExportSettings.IgnorePaging = CheckBox2.Checked;
            RadGrid1.ExportSettings.OpenInNewWindow = CheckBox3.Checked;
        }

Greetings,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
JM
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or