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

Add toolbar (enable/disable) commands

4 Answers 241 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 2
Iron
Jack asked on 03 Jun 2016, 05:57 AM

Is there a way to add commands to the SpreadSheet toolbar?

I am especially thinking about the enable/disable range button.

In a template/document scenario, one would want:

- to build templates where some cell ranges have to be disabled;

- to make documents based on such templates where disabled ranges (possibly including formulas) cannot be changed.

In case this is an oversight (enable/disable seems to be the only range property that cannot be set via the toolbar), please log a defect for a fix in a future version.

 

4 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 06 Jun 2016, 07:51 AM

Hello Jack,

You can use the following code to add a custom tool to the toolbar:

    toolbar: {
        home: kendo.spreadsheet.ToolBar.fn.options.tools["home"].concat([
            {
                type: "button",
                text: "Foo",
                spriteCssClass: "k-icon k-font-icon k-i-cog",
                click: function(e) {
                    window.alert("custom tool");
                }
            }
        ])
    }

This reuses the currently defined tools in the "Home" toolbar, and adds a custom button, via the Toolbar item configuration.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
TESI
Top achievements
Rank 1
answered on 23 Aug 2018, 09:49 AM

Hi Alex,

how to do this with Typescript? "ToolBar" object doesn't exist in kendo.spreadsheet namespace...

 

Regards

0
Ianko
Telerik team
answered on 27 Aug 2018, 05:55 AM
Hi,

As this is missing from the TypeScript definitions you can workaround that by casting to any type: 

var spreadsheetNS = <any>kendo.spreadsheet;
var tools = spreadsheetNS.ToolBar.fn.options.tools["home"].concat([
  {
      type: "button",
      text: "Foo",
      spriteCssClass: "k-icon k-font-icon k-i-cog",
      click: (e: any) => {
          console.log(e);
          window.alert("custom tool");
      }
  }
])
 
$("#sel").kendoSpreadsheet({
  toolbar: {
    home: tools
  }
})


Regards,
Ianko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
TESI
Top achievements
Rank 1
answered on 29 Aug 2018, 10:48 AM
thank you so much!
Tags
Spreadsheet
Asked by
Jack
Top achievements
Rank 2
Iron
Answers by
Alex Gyoshev
Telerik team
TESI
Top achievements
Rank 1
Ianko
Telerik team
Share this question
or