)
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 or remove custom controls into the Ribbon in the Spreadsheet

Platform: jQuery |
Control: ejSpreadSheet |
Published Date: September 19, 2017 |
Last Revised Date: May 22, 2019

Description

This Knowledge Base explains the way to add or remove the custom controls (button, dropdown….) in the ribbon in spreadsheet.

Solution

It can be achieved by using addTabGroup and  removeTabGroup methods.The following code examples demonstrates that how to perform this operation.

 

1. Render Spreadsheet control.

 

JS

 

    
    <ul id="targetData">
        <li><span>User</span></li>
        <li><span>Guest</span></li>
        <li><span>Admin</span></li>
    </ul>
    <div id="Spreadsheet"></div>
<script type="text/javascript">
    $(function () {
        $("#Spreadsheet").ejSpreadsheet({
            scrollSettings: {
                height: "100%",
                width: "100%"
            },
            sheets: [{
// window.data from http://js.syncfusion.com/demos/web/scripts/xljsondata.min.js  file                rangeSettings: [{ dataSource: window.data, showHeader: true }]
            }],
            loadComplete: "onLoadComplete"
        });
    });
 
  </script>

 

MVC

 

 
    <ul id="targetData">
        <li><span>User</span></li>
        <li><span>Guest</span></li>
        <li><span>Admin</span></li>
    </ul>
    <div id="Spreadsheet"></div>
 
<div style="height:550px;">
        @(Html.EJ().Spreadsheet<object>("Spreadsheet")
    .ScrollSettings(scroll =>
    {
        scroll.Height("100%");
        scroll.Width("100%");
    })
    .Sheets(sheet =>
    {
        sheet.RangeSettings(range =>
        {
            range.Datasource((IEnumerable<object>)ViewBag.Datasource).Add();
        }).Add();
    })
    .ClientSideEvents(events => events.LoadComplete("onLoadComplete"))
        )
</div>

 

ASP

 

  
    <ul id="targetData">
        <li><span>User</span></li>
        <li><span>Guest</span></li>
        <li><span>Admin</span></li>
    </ul>
 
    <ej:Spreadsheet ID="Spreadsheet" runat='server'>
            <ScrollSettings Width="100%" Height="100%" />
           <ClientSideEvents LoadComplete="onLoadComplete" />
     </ej:Spreadsheet>

 

2.  In the loadComplete client side event, we can customize the controls and add it to ribbon by using addTabGroup method.

 

JS

 

 
<script type="text/javascript">
    function onLoadComplete(args) {
        var tabIndex = 2, groupIndex = 4;
        var ribbonGrp = {
            alignType: ej.Ribbon.AlignType.Rows, text: "Custom button", content: [{
                groups: [{
                    id: "customBtn", splitButtonSettings: {
                        arrowPosition: ej.ArrowPosition.Bottom,
                        text: "login",
                        targetID: "targetData",
                        buttonMode: ej.ButtonMode.Dropdown,
                        contentType: "textandimage",
                        prefixIcon: "e-icon e-login e-uiLight"
                    }
                }], defaults: { type: ej.Ribbon.Type.SplitButton }
            }]
        };
        this.XLRibbon.addTabGroup(tabIndex, ribbonGrp, groupIndex); // To add the tab group in the ribbon INSERT tab. 
    }
  </script>

 

 

spreadsheet add or remove controls sample preview

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