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

How to remove Command itemtemplate in xls sheet

6 Answers 289 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sudheer
Top achievements
Rank 2
sudheer asked on 12 Feb 2009, 02:28 PM
Hi all,
i have a hierarchical grid,   i m using Command itemtemplate to show end user add ,edit ,delete,e.t.c . (not as columns inside grid)  if i try to export hierarchical grid to excel sheet  it is exporting add,edit, including with images(items included inside Command item template ). but i don't want to show all those options in XLS. how can i overcome this problem .

Anyhelp

6 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 12 Feb 2009, 03:54 PM
Hello Sudheer,

Set ExportOnlyData="true" either in the declaration or in code-behind.
Export to Microsoft Excel/Word/PDF/CSV

I hope this helps.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
sudheer
Top achievements
Rank 2
answered on 12 Feb 2009, 04:11 PM
Hi

Thanks for reply.
This works fine for level 1 grid .  but for level2  grid it's is not working.

Thanks for help
0
Princy
Top achievements
Rank 2
answered on 13 Feb 2009, 11:57 AM
Hi Sudheer,

You may try hiding the CommandItem for the detail table in the click event of the export button as shown below.

CS:
 protected void Button1_Click(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.Items) 
        { 
           //access the Detail table using the name property
            if (item.OwnerTableView.Name=="Detail"
            { 
 
                GridTableView childTable = (GridTableView)item.OwnerTableView; 
                    foreach (GridCommandItem cmditem in childTable.GetItems(GridItemType.CommandItem)) 
                    { 
                        cmditem.Visible = false
                    } 
                 
                
            } 
        } 
 
        RadGrid1.ExportSettings.OpenInNewWindow = true
        RadGrid1.ExportSettings.ExportOnlyData = true
        RadGrid1.MasterTableView.ExportToExcel(); 
 
        
    } 


Regards
Princy.
0
sudheer
Top achievements
Rank 2
answered on 13 Feb 2009, 04:20 PM
Hi princy,

Thanks for reply,

Even though my problem not get solved . in excel sheet  it is generating refresh image and add new record link of detail table.

please give a solution bcoz in excel it look's weird ,end user not happy.


0
Princy
Top achievements
Rank 2
answered on 16 Feb 2009, 05:51 AM
Hello Sudheer,

Check if you have set the Name property of the detail table on the aspx. Then try accessing the DetailTable using the name property as shown below:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server"
   <MasterTableView DataSourceID="SqlDataSource1" CommandItemDisplay="Top" Name="Master"
      <DetailTables> 
         <telerik:GridTableView DataSourceID="SqlDataSource2" CommandItemDisplay="Top" Name="Detail" runat="server" > 
            ..... 

cs:
protected void Button1_Click(object sender, EventArgs e)  
    {  
        foreach (GridDataItem item in RadGrid1.Items)  
        {  
           //access the Detail table using the name property 
            if (item.OwnerTableView.Name=="Detail")  
            {  
  
                GridTableView childTable = (GridTableView)item.OwnerTableView;  
                    foreach (GridCommandItem cmditem in childTable.GetItems(GridItemType.CommandItem))  
                    {  
                        cmditem.Visible = false;  
                    }  
                  
                 
            }  
        }  
  
        RadGrid1.ExportSettings.OpenInNewWindow = true;  
        RadGrid1.ExportSettings.ExportOnlyData = true;  
        RadGrid1.MasterTableView.ExportToExcel();  
  

Thanks
Princy.
0
sudheer
Top achievements
Rank 2
answered on 16 Feb 2009, 09:37 AM
Hi princy ,

My issue not at solved even if use your code . and i found debugger going inside while execution.
and in excel first column is getting empty.to resolve that i used below code .
(GRIDNAME.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem)["ExpandColumn"].Visible = false;  
 
foreach (GridDataItem dataItem in GRIDNAME.MasterTableView.Items)  
 
{  
 
dataItem["ExpandColumn"].Style["display"] = "none";  
 
dataItem["ExpandColumn"].Visible = false;  
 
}  
 

eventhough no chance , can u guide .
Tags
Grid
Asked by
sudheer
Top achievements
Rank 2
Answers by
Daniel
Telerik team
sudheer
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or