I found that the belowing code will cause a "TypeError: (intermediate value).toLowerCase is not a function", it seems that its caused by the toolbar template definition, but the same toolbar definition works fine in kendo grid
$(document).ready(function(){
$("#treelist").kendoTreeList({
columns: [
{ field: "Name" },
{ field: "Position" }
],
dataSource: {
data: [
{ id: 1, parentId: null, Name: "Jane Smith", Position: "CEO" },
{ id: 2, parentId: 1, Name: "Alex Sells", Position: "EVP Sales" },
{ id: 3, parentId: 1, Name: "Bob Price", Position: "EVP Marketing" }
],
},
toolbar: [
{ template: '<a class="k-button" onclick="customSave(this)" href="\\#"><span class="k-icon k-i-tick"></span>custom save</a>' },
{ template: '<a class="k-button" onclick="customCancel(this)" href="\\#"><span class="k-icon k-i-cancel"></span>custom cancel</a>' }
]
});
});
Is there any solution to slove this?(The button icon must be retained)
The proper way to create a toolbar with a click handler is:
toolbar: [
{
name: 'custom',
text: 'custom save',
imageClass: 'k-i-tick',
click: customSave
},
{
name: 'custom',
text: 'custom cancel',
imageClass: 'k-i-cancel',
click: customCancel
},
]
Here how it works:
name
must be custom
, because it's not a built-in command. If this attribute is omitted, you'll get an error. text
: whatever you want to display on the buttonimageClass
: the class
of the icon you want to display (k-icon
is implied)click
: the event handler I've created a jsFiddle to illustrate: https://jsfiddle.net/ueL8mrcr/