javascriptjquerykendo-uikendo-treelist

KendoUI add treelist toolbar template causes "TypeError: (intermediate value).toLowerCase is not a function"


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)


Solution

  • 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:

    I've created a jsFiddle to illustrate: https://jsfiddle.net/ueL8mrcr/