Events
You can subscribe to all ToolBar events and then use them to further customize the behavior of the ToolBar.
The example below demonstrates how to use the Click
event that the ToolBar triggers when the user clicks on a tool.
@using Kendo.Mvc.UI
@(Html.Kendo().ToolBar()
.Name("ToolBar")
.Items(items =>
{
items.Add().Type(CommandType.Button).Text("Button 1").Id("button1");
items.Add().Type(CommandType.Button).Text("Button 2").Id("button2");
items.Add().Type(CommandType.Separator);
items.Add().Type(CommandType.SplitButton).Text("Split Button").Id("mainButton").MenuButtons(menuButtons =>
{
menuButtons.Add().Text("Action 1").Id("action1");
menuButtons.Add().Text("Action 2").Id("action2");
menuButtons.Add().Text("Action 3").Id("action3");
});
})
.Events(e => e.Click("onClick"))
)
<script>
function onClick(e) {
console.log("ToolBar 'click' event is fired for element with id: " + e.id);
}
</script>