我在 Kendo 网格工具栏中有一些项目。
一切正常除了最后一个名为“test”的项目。
点击事件未触发定义的操作。
问题是:如何解决在同一个 Controller 中触发另一个 AngularJS 函数的问题?
toolbar: [
{ template: kendo.template($("#preparedViewsToolbar").html()) },
{ name: "create" },
{ name: "save" },
{ name: "cancel" },
{
name: "test",
text: "testme",
click: function(e){
console.log("TEST");
}
}
]
感谢您的帮助和建议。
最佳答案
这是因为 Kendo UI 不理解工具栏项上的 click
属性。不支持[ reference ]。相反,您应该为工具栏项定义一个模板,并在该模板中您可以绑定(bind)您的单击功能。
<div id="grid"></div>
<script id="template" type="text/x-kendo-template">
<a class="k-button" href="\#" onclick="return toolbar_click()">Command</a>
</script>
<script>
function toolbar_click() {
console.log("Toolbar command is clicked!");
return false;
}
$("#grid").kendoGrid({
toolbar: [
{ name: 'create' },
{ name: 'save' },
{ name: 'cancel' },
{ template: kendo.template($("#template").html()) }
],
columns: [
{ title: 'Name', field: "name" },
{ title: 'Age', field: "age" }
],
dataSource: [
{ name: "Jane Doe", age: 30 },
{ name: "John Doe", age: 33 }
]
});
</script>
关于javascript - Kendo Grid 工具栏项目未触发单击功能 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24508878/