Exporting only selected rows

11 posts, 0 answers
  1. Debbie
    Debbie avatar
    27 posts
    Member since:
    Jul 2008

    Posted 30 Sep 2008 Link to this post

    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
  2. Debbie
    Debbie avatar
    27 posts
    Member since:
    Jul 2008

    Posted 30 Sep 2008 Link to this post

    nevermind, found a solution.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Debbie
    Debbie avatar
    27 posts
    Member since:
    Jul 2008

    Posted 30 Sep 2008 Link to this post

    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
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 01 Oct 2008 Link to this post

    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.
  6. Debbie
    Debbie avatar
    27 posts
    Member since:
    Jul 2008

    Posted 01 Oct 2008 Link to this post

    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();  
            } 
  7. Sic
    Sic avatar
    1 posts
    Member since:
    Nov 2008

    Posted 28 Nov 2008 Link to this post

    did you find a solution to this issue? We're having the same problem

    Thx,
    Greg
  8. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 01 Dec 2008 Link to this post

    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.
  9. Vaibhav
    Vaibhav avatar
    15 posts
    Member since:
    Feb 2014

    Posted 08 Sep 2014 in reply to Yavor Link to this post

    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
  10. Allen
    Allen avatar
    50 posts
    Member since:
    Mar 2011

    Posted 05 Jun 2015 Link to this post

    Doesn't setting these to invisible mean they have to be reset to visible after the export completes?
  11. Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 10 Jun 2015 Link to this post

    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
  12. Matej
    Matej avatar
    2 posts
    Member since:
    Jun 2015

    Posted 16 Oct 2015 in reply to Vaibhav Link to this post

    Vaibhav said:
    item.Visible = false;

    item.Display = false;  works for me

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017