)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to add a template in ribbon backstage

Platform: jQuery |
Control: ejSpreadSheet |
Published Date: March 5, 2018 |
Last Revised Date: May 22, 2019

Description

This knowledge base explains how to add a template in ribbon backstage.

Solution

It can be achieved by using ‘loadComplete’ client-side event in the Spreadsheet. Here we have added button as a template in the ribbon backstage and we will update the template data by using “openTemplate()” method, when template button is clicked.

The following code example demonstrate how to add template in ribbon backstage,

 

HTML

 

 
<div id="Spreadsheet"></div>
 

 

JS

 

  1. Render the Spreadsheet control.

 

 
$("#Spreadsheet").ejSpreadsheet({
    loadComplete: "onLoadComplete"
});
 

 

RAZOR

 

 
@(Html.EJ().Spreadsheet<object>("Spreadsheet")
    .ClientSideEvents(
        events => events.LoadComplete("onLoadComplete")
    )
)
 

 

ASPX

 

 
<ej:Spreadsheet ID="Spreadsheet" runat="server">
    <ClientSideEvents LoadComplete="onLoadComplete" />
</ej:Spreadsheet>
 

 

JS

 

  1. Use “loadComplete” client-side event to add template in ribbon backstage.

 

 
function onLoadComplete() {
    var spreadsheetID = "Spreadsheet", backstageNewElem = $("#" + spreadsheetID + "_backstagetabnew"), backstageItem, templateID = spreadsheetID + "_bstab_template", buttonOption;
 
    //Adding Backstage Item 
    if (!backstageNewElem.find("#" + templateID).length) {
        backstageItem = '<div class="e-spreadsheet-template"><button id="' + templateID + '"></button><span></span></div>',
        buttonOption = { height: 120, width: 150, contentType: "textOnly", text: "Template", click: "openTemplate" };
        backstageNewElem.append(backstageItem);
        $("#" + templateID).ejButton(buttonOption);
    }
}
 
function openTemplate(args) {
    //To update template data in the Spreadsheet
    var spreadsheetID = "Spreadsheet", xlObj = $("#" + spreadsheetID).data("ejSpreadsheet"), sheetIdx = xlObj.getActiveSheetIndex(), templateData = { dataSource: [{ Product: "XYZ", Price: "2000", Quantity: "10", Price: "20", Amount: "200" }], showHeader: "true", startCell: "A1" };
    xlObj.updateRange(sheetIdx, templateData);
    $("#" + spreadsheetID + "_Ribbon").data("ejRibbon").hideBackstage();
}

 

The following is displayed as output of adding custom template in the Spreadsheet ribbon backstage.

 

spreadsheet ribbon backstage sample preview

Figure: Spreadsheet Ribbon Backstage.

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon