Articles in this section
Category / Section

How to add or remove custom controls into the Ribbon in the Spreadsheet

1 min read

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

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied