Set item-wise custom template

17 Feb 20222 minutes to read

The Toolbar supports adding template commands using the template property. Template property can be given as the HTML element that is either a string or a query selector.

As a string

The HTML element tag can be given as a string for the template property. Here, the checkbox is rendered as a HTML template.

template: "<div><input type='checkbox' id='check1' checked=''>Accept</input></div>"

As a selector

The template property also allows getting template content through query selector. Here, checkbox ‘ID’ attribute is specified in the template.

template: "#Template"
@using Syncfusion.EJ2.Navigations;

<div>
    <div>
        @(Html.EJS().Toolbar("defaultToolbar")
            .Items(new List<ToolbarItem> {
                new ToolbarItem { Text = "Cut" },
                new ToolbarItem { Type = ItemType.Separator },
                new ToolbarItem { Text = "Paste" },
                new ToolbarItem { Type = ItemType.Separator },
                new ToolbarItem { Template = "<div><input type='checkbox' id='check1' checked=''>Accept</input></div>" },
                new ToolbarItem { Text = "Undo" },
                new ToolbarItem { Text = "Redo" },
                new ToolbarItem { Template = "#Template" }
            })
            .Width("330")
            .Render()
        )
    </div>
    <button id='Template' class='e-btn'>Template</button>
</div>
public ActionResult Index()
{
    return View();
}