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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add custom icon To Toolbar

Platform: ASP.NET Web Forms |
Control: Gantt |
Published Date: July 28, 2017 |
Last Revised Date: May 28, 2019

In Gantt, we can customize the toolbar with custom icons and can bind click event to the icon using the toolbarSettings.customToolbarItems property. We can define the required custom toolbar items in this property and handle the click events using toolbarClick client side event.

There are two ways to define custom toolbar items in Gantt,

By using CSS text:

We need to define the required custom toolbar item in the customToolbarItems.text property. And by using this text value, we can bind the event for the custom icon in toolbarClick event. Find the below code example for details.

<style type="text/css" class="cssStyles">
  .Reset:before {
      content: "\e677";
  }
</style>
$("#GanttContainer").ejGantt({
        //...
        toolbarSettings: {
            showToolbar: true,
            customToolbarItems: [{
                text: "Reset",
                tooltipText: "Reset"
            }],
        },
        toolbarClick: function (args) {
            if (args.itemName == "Reset") {
                // actions to be taken while clicking custom toolbar item
            }
        },
})
 

By using template:

We can also customize the toolbar items by providing the JsRender template to the templateID property. Find the below code example for details.

<script id="ColumnVisibility" type="text/x-jsrender">
        <input id="dropdownContainer" />
</script>
$("#GanttContainer").ejGantt({
        //...
        toolbarSettings: {
            showToolbar: true,
            customToolbarItems: [{
                templateID: "#ColumnVisibility",
                tooltipText: "Column Visibility"],
 
        },
        create: function(args) {
            $("#dropdownContainer").ejDropDownList({
                height: 30,
                dataSource: dropData,
                showCheckbox: true,
                field: {
                    text: "text",
                    value: "value",
                    selected: "selected"
                },
                checkChange: function(args) {
                    var ganttObj = $("#GanttContainer").data("ejGantt");
 
                    if (args.isChecked == false) {
                        ganttObj.hideColumn(args.selectedText);
                    } else {
                        ganttObj.showColumn(args.selectedText);
                    }
                }
            });
        }
})
 

You can find a sample to show custom toolbar items in Gantt below,

Sample

2X faster development

The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
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.

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