Search code examples
cssiconskendo-menu

How to put icons into a Kendo Menu?


I have the following Kendo Menu:

<div id="menu"></div>

<script>
    console.log("executes")
    $("#menu").kendoMenu({
        dataSource: [{
            text: "menu", icon: "k-icon k-i-more-horizontal", items: [
                { text: "Edit", spriteCssClass: "k-icon k-i-edit" },
                { text: "Delete", spriteCssClass: "k-icon k-i-delete" },
            ]
        }

        ]
    });
</script>

Since spriteCssClass is not recommended [https://www.telerik.com/forums/spritecssclass-is-not-working-with-icons-in-latest-version] , I tried icon:... as you can see in the first line of the dataSource. But that does not work, too.

How can I put Kendo some icons into a Kendo Menu ?


Solution

  • I solved it simply putting a < span > into text and setting encoded: false.

       $("#menu").kendoMenu({
            dataSource: [{
                text: "<span class=\"k-icon k-i-more-horizontal\"></span>", encoded: false, items: [
                    { text: "<span class=\"k-icon k-i-edit\"></span><span>Edit</span>", encoded: false },
                    { text: "<span class=\"k-icon k-i-delete\"></span><span>Delete</span>", encoded: false }
                ]
            }]
        });