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

Exporting only selected rows

10 Answers 324 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Debbie
Top achievements
Rank 1
Debbie asked on 30 Sep 2008, 07:53 PM
Is there a way to only export the selected rows of a RadGrid?  What I need to do is provide a view of only selected rows -- so I plan to use export to PDF (in a new window) where the user can print the grid contents. 

thanks!
Debbie

10 Answers, 1 is accepted

Sort by
0
Debbie
Top achievements
Rank 1
answered on 30 Sep 2008, 09:01 PM
nevermind, found a solution.
0
Debbie
Top achievements
Rank 1
answered on 30 Sep 2008, 09:23 PM

I spoke to quickly, the fix that I found on another post didn't work.

I'm trying to only display selected rows when exporting to EXCEL.

 foreach (GridDataItem item in grid.Items)  
{  
                     
        itemitem.Visible = item.Selected;  
                      

But this doesn't appear to work.  I have two rows in my grid, only one row selected, but export is still exporting all rows in the grid.

Any help / suggestions are appreciated.

thanks!
Debbie
0
Princy
Top achievements
Rank 2
answered on 01 Oct 2008, 05:55 AM
Hello Debbie,

You can try thie following code snippet and see if it helps.

 protected void Button1_Click(object sender, EventArgs e) 
    { 
          foreach (GridDataItem item in RadGrid1.Items)  
        {  
            if (item.Selected==false)  
            {  
                item.Visible = false;  
            }  
        }  
        RadGrid1.ExportSettings.ExportOnlyData = true;  
        RadGrid1.ExportSettings.OpenInNewWindow = true;  
        RadGrid1.MasterTableView.ExportToExcel();  
    }  
         

Princy.
0
Debbie
Top achievements
Rank 1
answered on 01 Oct 2008, 02:21 PM
that is what I'm doing, but that isn't working.  Here's my code I'm running...
protected void btnExport_Click(object sender, EventArgs e)  
        {  
 
            SetForRefresh(false);  
            switch (tpTaskMgmt.ActiveTabIndex)  
            {  
                case (int) Tabs.Unassigned:  
                    ExportGrid(gridUnassigned, true);  
                    break;  
                case (int)Tabs.MyTasks:  
                    ExportGrid(gridMyTasks, true);  
                    break;  
                case (int)Tabs.ReplenishReady:  
                    ExportGrid(gridReplenishReady, true);  
                    break;  
 
            }              
 
        }  
 
        private static void ExportGrid(RadGrid grid, bool selectedOnly)  
        {  
              
            if (selectedOnly)  
            {  
                foreach (GridDataItem item in grid.Items)  
                {                      
                       item.Visible = item.Selected;                      
                }  
            }  
            grid.MasterTableView.Columns.FindByUniqueName("colSelect").Visible = false;  
            grid.ExportSettings.ExportOnlyData = true;              
            grid.ExportSettings.OpenInNewWindow = true;                          
            grid.MasterTableView.ExportToWord();  
        } 
0
Sic
Top achievements
Rank 1
answered on 28 Nov 2008, 09:20 PM
did you find a solution to this issue? We're having the same problem

Thx,
Greg
0
Yavor
Telerik team
answered on 01 Dec 2008, 06:21 AM
Hello Sic,

Attached to this message, is a small application, which handles a similar case.
I hope it helps.

All the best,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Vaibhav
Top achievements
Rank 1
answered on 08 Sep 2014, 11:53 AM
Hi.
I need  to export only selected rows to excel.
I am able to hide columns before exporting.
I have searched a lot regarding hiding unselected rows/Exporting only selected rows in telerik threads.
In all my search results I found the below line of code. 

‚Äč if (Grid.SelectedItems.Count != 0)
{
foreach (GridDataItem item in Grid.MasterTableView.Items)
{
if (!item.Selected)
item.Visible = false;
}
} My excel format is"BIFF".
Its very urgent.
Please help
0
Allen
Top achievements
Rank 2
Iron
Veteran
answered on 05 Jun 2015, 03:00 PM
Doesn't setting these to invisible mean they have to be reset to visible after the export completes?
0
Eyup
Telerik team
answered on 10 Jun 2015, 12:59 PM
Hi Allen,

Any changes made while exporting won't affect the overall settings of the grid and these changes won't persist after the export action.

Regards,
Eyup
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Matej
Top achievements
Rank 1
answered on 16 Oct 2015, 10:25 PM

[quote]Vaibhav said:
item.Visible = false;
[/quote]

item.Display = false;  works for me

Tags
Grid
Asked by
Debbie
Top achievements
Rank 1
Answers by
Debbie
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Sic
Top achievements
Rank 1
Yavor
Telerik team
Vaibhav
Top achievements
Rank 1
Allen
Top achievements
Rank 2
Iron
Veteran
Eyup
Telerik team
Matej
Top achievements
Rank 1
Share this question
or