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

Need example for export to excel inside radgrid.

1 Answer 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thunaivan
Top achievements
Rank 1
Thunaivan asked on 19 Feb 2009, 09:36 AM
Hi all,

Is there any Possibility to place  export to excel in side Radgrid (Beside to refresh icon). and export grid to excel.

I tried using  commanditem template it's working but while exporting some constraints i m facing  like(exporting referesh ,Add new record ,export to excel images and links ) even if i use ExportOnlydata="true" property also.

It would be great any help.


1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Feb 2009, 10:14 AM
Hi Thunaivan,

Try the following code snippet for hiding the command item when exporting from RadGrid.

CS:
bool isExcelExport = false
protected void Button1_Click(object sender, EventArgs e) 
    this.RadGrid1.ExportSettings.OpenInNewWindow = true
    this.RadGrid1.ExportSettings.ExportOnlyData = true
    this.RadGrid1.ExportSettings.IgnorePaging = true
    this.RadGrid1.MasterTableView.ExportToExcel();  
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    if (isExcelExport && e.Item is GridCommandItem) 
    { 
        GridCommandItem cmditem = (GridCommandItem)e.Item; 
        cmditem.Visible = false
    } 
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    if (e.CommandName == RadGrid.ExportToExcelCommandName) //Set the CommandName of button as ExportToExcel in ASPX  
    { 
        isExcelExport = true
        RadGrid1.ExportSettings.IgnorePaging = true
    } 

You can also refer the help article explaining Exporting tips and tricks.

Thanks,
Shinu.
Tags
Grid
Asked by
Thunaivan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or