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

[Solved] Exporting selected items of the grid from Multiple Pages

1 Answer 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dev
Top achievements
Rank 1
Dev asked on 05 Feb 2013, 08:13 PM
Hi,

How can I achieve exporting the items of the grid from Multiple Pages. For example if I have a grid and I selected 3 items from page1 , 5 items from page 2 and 10 items from page 7. How do I export only the items that I have selected without any performance issues. I have custom paging enabled.

Thanks,

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 08 Feb 2013, 10:17 AM
Hello,

You can use the following approach:
Copy Code
List<int> selectedIndexes = new List<int>();
protected void Button1_Click(object sender, EventArgs e)
{
    ExportToExcel();
}
private void ExportToExcel()
{
    dgReconcileData.ExportSettings.IgnorePaging = true;
    dgReconcileData.ExportSettings.OpenInNewWindow = true;
    dgReconcileData.ExportSettings.OpenInNewWindow = true;
 
    foreach (string index in dgReconcileData.SelectedIndexes)
    {
        selectedIndexes.Add(int.Parse(index));
    }
    dgReconcileData.MasterTableView.ExportToExcel();
}
protected void dgReconcileData_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (selectedIndexes.Count > 0 && e.Item is GridDataItem)
    {
        e.Item.Display = selectedIndexes.Contains(e.Item.ItemIndex);
    }
}

That should do the trick. Please give it a try and let me know about if it works for you.

Greetings,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Dev
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or