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

Disable Export to Excel

6 Answers 421 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manav
Top achievements
Rank 1
Manav asked on 17 Mar 2011, 05:48 PM
Is there anyway I can disable the export to excel on my grids on the right click menu?

6 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 19 Mar 2011, 10:57 PM
Hello Manav,

It depends on your scenario. Generally it would be a better approach not to show the export option rather than to cancel the export. If you post more details I will be able to provide straight-to-the-point answer.

Best regards,
Daniel
the Telerik team
0
Manav
Top achievements
Rank 1
answered on 20 Mar 2011, 01:07 AM
Hi Daniel,
  Basically, I do not want the user to be able to download the data from my grid to excel. How do i do this? Also, is there a way i can do it on a master page and it gets applied to all the grids?
0
Manav
Top achievements
Rank 1
answered on 28 Mar 2011, 02:50 PM
Hi Daniel,
  Is there any update on this issue?
In case the question is still not clear, I do not want the user to be able to download the data from the grid as this may be confidential data which may be in the grid

Can you please advice.
Thanks
0
Daniel
Telerik team
answered on 01 Apr 2011, 08:03 AM
Hello Manav,

A possible approach would be to remove the Export item from the context menu:
<telerik:RadContextMenu ID="RadContextMenu1" runat="server" OnPreRender="RadContextMenu1_PreRender">
    <Targets>
        <telerik:ContextMenuElementTarget ElementID="outerDiv" />
    </Targets>
    <Items>
        <telerik:RadMenuItem Text="Export" />
        <telerik:RadMenuItem Text="Edit" />
        <telerik:RadMenuItem Text="Delete" />
    </Items>
</telerik:RadContextMenu>


protected void RadContextMenu1_PreRender(object sender, EventArgs e)
{
    if (!SomeCondition)
    {
        RadContextMenu rcm = sender as RadContextMenu;
        rcm.Items.Remove(rcm.FindItemByText("Export"));
    }
}

Generally speaking, the latest point where it is possible to cancel the export is on GridExporting event.
void RadGrid1_GridExporting(object sender, GridExportingArgs e)
{
    if (!SomeCondition)
    {
        Response.Redirect(Request.Url.ToString());
    }
}

Best regards,
Daniel
the Telerik team
0
Manav
Top achievements
Rank 1
answered on 01 Apr 2011, 10:39 AM
Hi Daniel,
   Apologies but looks like you havent got my question still. I dont have a context menu at all. I only have the grid in my complete page.However,  the standard windows right click menu shows an option of Export to Excel on the Radgrid
0
Daniel
Telerik team
answered on 01 Apr 2011, 12:05 PM
Hello Manav,

I thought you use a context menu because you said:
I can disable the export to excel on my grids on the right click menu?

The option that you are referring to has nothing to do with Telerik RadControls. This functionality is added to the context menu of your browser by Microsoft Office.

Best regards,
Daniel
the Telerik team
Tags
Grid
Asked by
Manav
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Manav
Top achievements
Rank 1
Share this question
or