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

How to hide toolbar, formula bar, make entire file read only and allow excel export preview?

8 Answers 508 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
gc_0620
Top achievements
Rank 1
gc_0620 asked on 25 Feb 2016, 01:00 AM

Using UI for ASP.NET AJAX Q1 2016, with VS 2013. My situation is below:
 
 1a) Exporting SQL Data to users weekly basis into an Excel File via SSIS Package. Works Fine...
 
 1b) Super User add/edit's some Cell (Not row/column) data elements in that Excel File based on data from a 3rd Party.
 
 Now Super user want to Publish that Excel Data into Web just as read only to other user's.
 
 My intention:
 
 2a) How to hide toolbar, formula bar, Making Cells/Formula's read only and just show export to Excel Button using below Prototype.


 2b) Possible when exporting to Excel, instead of Save/Save as (in #2a),  allow open/save/cancel like below RadGrid Demo. 99% of the time, user will prefer to open the file prior to save it.

 

Thanks a lot.
 
 gc_0620
 

 

8 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 29 Feb 2016, 02:59 PM
Hello gc_0620,

You can hide the ToolBar and the formula bar on the client with jQuery:
$telerik.$(".rssToolbarWrapper").hide();
$telerik.$(".rssFormulaBar").hide();

You can prevent the user from editing a cell (or a range of cells) through the SpreadsheetRange object's set_enabled(false) method.

As for the Open file option when using the RadClientExportManager to export the Spreadsheet, it is available in Chrome and Firefox and it is not available in IE11.

Regards,
Ivan Danchev
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
0
gc_0620
Top achievements
Rank 1
answered on 01 Mar 2016, 06:24 PM

Thanks Ivan,

Appreciate for your solution. I have some other issues that I need some help:

1) Disallow users to Delete any Column or Rows. Currently I can do it via right mouse click.

2) Disallow users to add new sheet or delete existing sheet or sheet's.

3) Possible to expand the column length like one can do it in regular excel file (via dragging its header)? 

As per Super user (creator of the original file), regular users must not perform above tasks outlined in item #1 and #2. 

If regular user's want to manipulate data, they should export existing file into Excel and make changes there.

Please refer to attached for my intention.

Thanks again

gc_0620

0
gc_0620
Top achievements
Rank 1
answered on 01 Mar 2016, 06:31 PM

Ivan, if you think disallow/disable user's to perform both options (i.e. Hide/Delete) in any columns or rows (item #1 in previous post), that is fine.

 

gc_0620

0
Ivan Danchev
Telerik team
answered on 02 Mar 2016, 03:37 PM
Hello gc_0620,

1. Preventing the user from deleting rows and columns can be done by canceling the ContextMenu's OnClientItemClicking event:
<telerik:RadSpreadsheet runat="server" ID="RadSpreadsheet1">
    <ContextMenus>
        <RowHeaderContextMenu OnClientItemClicking="OnClientItemClicking">
        </RowHeaderContextMenu>
        <ColumnHeaderContextMenu OnClientItemClicking="OnClientItemClicking">
        </ColumnHeaderContextMenu>
    </ContextMenus>
</telerik:RadSpreadsheet>

function OnClientItemClicking(sender, eventArgs) {
    var selectedItemValue = eventArgs.get_item().get_value();
 
    if (selectedItemValue === "CommandDeleteRow" || selectedItemValue === "CommandDeleteColumn") {
        eventArgs.set_cancel(true);
    }
}
2. Currently you cannot prevent the user from adding or deleting sheets.

3. Dragging to resize a column is supported.

Regards,
Ivan Danchev
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
0
gc_0620
Top achievements
Rank 1
answered on 02 Mar 2016, 05:51 PM

Thanks Ivan,

Your solution works. But I am seeing attached error message in Visual Studio. What I am doing wrong? Am I missing something? But the result set works based on your suggestions as well as there are no error's after rebuilding the solution.

Codes are below. Please advice.

Thanks

gc_-620

---------

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<!DOCTYPE html>
 
 
<head runat="server">
 
    <title>Telerik ASP.NET Example</title>
 
    <script type="text/javascript" src="scripts.js"></script>
 
</head>
 
<body>
 
    <form id="form1" runat="server">
 
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
 
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
 
 
                function exportFile() {
                    var spreadsheet = $find("<%= RadSpreadsheet1.ClientID %>");
 
                        spreadsheet.saveAsExcel();
                    }
 
                   function OnClientItemClicking(sender, eventArgs) {
                        var selectedItemValue = eventArgs.get_item().get_value();
 
                        if (selectedItemValue === "CommandDeleteRow" || selectedItemValue === "CommandDeleteColumn") {
                            alert("Prohibited !!!");
 
                            eventArgs.set_cancel(true);
                        }
                    }
 
            </script>
        </telerik:RadCodeBlock>
 
        <div>
            <telerik:RadButton runat="server" ID="btnExport" AutoPostBack="false" OnClientClicked="exportFile" Text="Export to Excel File"></telerik:RadButton>
            <br />
            <telerik:RadSpreadsheet runat="server" ID="RadSpreadsheet1">
 
                <ContextMenus>
                    <RowHeaderContextMenu OnClientItemClicking="OnClientItemClicking">
                    </RowHeaderContextMenu>
                    <ColumnHeaderContextMenu OnClientItemClicking="OnClientItemClicking">
                    </ColumnHeaderContextMenu>
                </ContextMenus>
 
                <Toolbar>
                    <telerik:SpreadsheetToolbarTab Text="Home">
                        <telerik:SpreadsheetToolbarGroup>
                            <telerik:SpreadsheetTool Name="Undo" ShowLabel="false" />
                            <telerik:SpreadsheetTool Name="Redo" ShowLabel="false" />
                        </telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetToolbarGroup>
                            <telerik:SpreadsheetTool Name="Paste" ShowLabel="false" />
                            <telerik:SpreadsheetTool Name="Cut" ShowLabel="false" />
                            <telerik:SpreadsheetTool Name="Copy" ShowLabel="false" />
                        </telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetToolbarGroup>
                            <telerik:SpreadsheetTool Name="Bold" ShowLabel="false" />
                            <telerik:SpreadsheetTool Name="Italic" ShowLabel="false" />
                            <telerik:SpreadsheetTool Name="Underline" ShowLabel="false" />
                        </telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetToolbarGroup>
                            <telerik:SpreadsheetTool Name="FontFamily" ShowLabel="false" />
                        </telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetToolbarGroup>
                            <telerik:SpreadsheetTool Name="FontSize" ShowLabel="false" />
                        </telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetToolbarGroup>
                            <telerik:SpreadsheetTool Name="BackgroundColor" ShowLabel="false" />
                            <telerik:SpreadsheetTool Name="TextColor" ShowLabel="false" />
                        </telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetToolbarGroup>
                            <telerik:SpreadsheetTool Name="BorderType" ShowLabel="false" />
                            <telerik:SpreadsheetTool Name="BorderColor" ShowLabel="false" />
                        </telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetToolbarGroup>
                            <telerik:SpreadsheetTool Name="HorizontalAlignment" ShowLabel="false" />
                            <telerik:SpreadsheetTool Name="VerticalAlignment" ShowLabel="false" />
                        </telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetToolbarGroup>
                            <telerik:SpreadsheetTool Name="TextWrap" ShowLabel="false" />
                            <telerik:SpreadsheetTool Name="MergeCells" ShowLabel="false" />
                        </telerik:SpreadsheetToolbarGroup>
                    </telerik:SpreadsheetToolbarTab>
 
                </Toolbar>
 
            </telerik:RadSpreadsheet>
 
        </div>
 
    </form>
 
</body>
 
</html>

________

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
 
public partial class _Default : System.Web.UI.Page
{
    private const string ProviderSessionKey = "Telerik.Web.Examples.SpreadSheet.ContextMenu.DefaultCS";
 
    protected void Page_Init(object sender, EventArgs e)
    {
        SpreadsheetDocumentProvider provider;
 
        if ((Session[ProviderSessionKey] == null) || (!IsPostBack))
        {
            provider = new SpreadsheetDocumentProvider(Server.MapPath("~/App_Data/Spreadsheet-ToolbarDemo.xlsx"));
 
            Session[ProviderSessionKey] = provider;
        }
        else
        {
            provider = (SpreadsheetDocumentProvider)Session[ProviderSessionKey];
        }
 
        RadSpreadsheet1.Provider = provider;
    }
}

0
Ivan Danchev
Telerik team
answered on 03 Mar 2016, 03:16 PM
Hello gc_0620,

We can confirm that the error in the Designer when ContextMenus are declared is a bug. We logged it and will fix it in one of our next releases.

You can track the bug's status on our Feedback Portal and vote/rate it. 

As a token of gratitude for reporting the bug I updated your Telerik points. 

Regards,
Ivan Danchev
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
0
gc_0620
Top achievements
Rank 1
answered on 03 Mar 2016, 03:25 PM

Thanks Ivan, appreciate for your help. Please keep us posted when this issue is resolved.

Best Regards

gc_0620

0
Ivan Danchev
Telerik team
answered on 07 Mar 2016, 03:30 PM
Hello gc_0620,

We will let you know when the bug is fixed and this will also be reflected in its item in the Feedback Portal.

Regards,
Ivan Danchev
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
Tags
Spreadsheet
Asked by
gc_0620
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
gc_0620
Top achievements
Rank 1
Share this question
or