How to put icons into a Kendo Menu?

2.5k Views Asked by At

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 ?

2

There are 2 best solutions below

0
thestruggleisreal On BEST ANSWER

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 }
            ]
        }]
    });
3
Ceco Milchev On

You can also use FontAwesome icons in the Kendo UI Menu as explained in the following article: