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

[Solved] Grid Exporting

2 Answers 155 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jols
Top achievements
Rank 2
Jols asked on 14 May 2009, 01:46 PM
hello to all expert

                Good Day! i would like to ask some help here coz i wasn't able to configure this out..here's my scenario when the user select on the grid, the selected row only be export to excel but i try to follow the other advice using the radgrid.rebind() but the problem is it  show s all the record, but i want only the selected row will be exported to excel..anyway here is my code
 protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e) 
        { 
           
 
                switch (e.Item.Value)//parentroot 
                { 
                    case "2"://Excel 
                        RadMenuItem Excel = e.Item; 
                         
                        foreach (GridDataItem item in RdGridMainpage.Items) 
                        { 
                           
                            if (item.Selected == false) 
                            { 
 
                                item.Visible = false;     
                                
                            } 
                             
                            
 
                        } 
                        RdGridMainpage.Rebind(); 
                        RdGridMainpage.ExportSettings.ExportOnlyData = true
                        RdGridMainpage.ExportSettings.IgnorePaging = true
                        RdGridMainpage.ExportSettings.OpenInNewWindow = true
                        RdGridMainpage.ExportSettings.FileName = "Request Data"
                        RdGridMainpage.MasterTableView.ExportToExcel();   
                        break; 
===================================================== 
and my need_Datasource 
 
 protected void RdGridMainpage_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
        { 
            AppGlobalDeclarations gConn = new AppGlobalDeclarations(); 
            DataSet ds; 
           
            ds = SqlHelper.ExecuteDataset(gConn.SQLConnection, CommandType.StoredProcedure, "spu_Chs_tblRequestTicket_Mainpage_SelectExport1"); 
                                         
            try 
            { 
                 
                this.RdGridMainpage.DataSource = ds
                this.RdGridMainpage.Columns[3].Visible = false
                this.RdGridMainpage.Columns[4].Visible = true
            } 
            catch (Exception ex) 
            { throw ex; } 
        } 
 
 what should i do please help..

sample codes is highly appreciated

thanks to all

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 May 2009, 02:26 PM
Hello Jols,

You need not rebind your grid after looping through the selected item collection. You can avoid the following line and it should work as expected.
c#:
protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)   
        {   
            switch (e.Item.Value)//parentroot   
                {   
                    case "2"://Excel   
                        RadMenuItem Excel = e.Item;   
                           
                        foreach (GridDataItem item in RdGridMainpage.Items)   
                        {                              
                            if (item.Selected == false)   
                            {    
                                item.Visible = false;                                  
                            }                        
                        }               
                        RdGridMainpage.ExportSettings.ExportOnlyData = true;   
                        RdGridMainpage.ExportSettings.IgnorePaging = true;   
                        RdGridMainpage.ExportSettings.OpenInNewWindow = true;   
                        RdGridMainpage.ExportSettings.FileName = "Request Data";   
                        RdGridMainpage.MasterTableView.ExportToExcel();   
                   break;   
            }  
        }  

Thanks
Shinu.
0
Jols
Top achievements
Rank 2
answered on 15 May 2009, 04:39 AM
that codes that you've given is working but i have a GridButtonColumn name the category  and one GridBoundColumn which handle same data(category) heres  my aspx
<telerik:GridButtonColumn CommandName="Select" DataTextField="fcSubject" HeaderText="Subject"  
                          UniqueName="SubjectButton"  > 
     <ItemStyle HorizontalAlign="Left" /> 
     </telerik:GridButtonColumn> 
                               <telerik:GridBoundColumn Visible ="False"  DataField="fcsubject" HeaderText="Subject" UniqueName="SubjectData" > 
         <ItemStyle HorizontalAlign="Left" /> 
         </telerik:GridBoundColumn> 

and i tried this code given by member of telerik
foreach (GridDataItem item in RdGridMainpage.Items)   
{   
   
string requestid = item["Request ID"].Text.ToString();   
   
if (item.Selected == true)   
   
{   
   
//SendtoMicrOffice(requestid);   
this.RdGridMainpage.Columns.FindByUniqueNameSafe("SubjectButton").Visible = false;   
this.RdGridMainpage.Columns.FindByUniqueNameSafe("Subjectdata").Visible =true;   
   
}   
else   
   
{   
   
item.Visible =false;   
}   
   
}   
 
RdGridMainpage.ExportSettings.ExportOnlyData =true;   
RdGridMainpage.ExportSettings.IgnorePaging =true;   
RdGridMainpage.ExportSettings.OpenInNewWindow =true;   
RdGridMainpage.MasterTableView.ExportToExcel();   
   
 
still those two codes hide and show still not working..please help

sample codes is highly appreciated

thanks to all


Tags
Grid
Asked by
Jols
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Jols
Top achievements
Rank 2
Share this question
or