Kendo UI - tooltip in the grid

I am trying to create a tooltip for my grid as follows:

$("#grid").kendoTooltip({
    autoHide: true,
    showOn: "mouseenter",
    width:125,
    height:125,
    position: "right",
    filter: ".k-grid-content a.hasTooltip",
    content: kendo.template($("#storeTerritory").html())
});

Template Definition:

<script type="text/x-kendo-template" id="storeTerritory">
<div class="tooltipcontent">
    #for(var i = 0; i < Territories.length; i++){#
        #if (Territories != 'null' && Territories != '')  {#
            <p>#=Territories[i].TerritoryDescription#</p>
        #} else{#
            <p>Information not available</p>
      #}#
    #}#
</div>
</script>

I installed the sample here:
http://jsbin.com/iJunOsa/21/edit

I get an error ReferenceError: Territories is not definedin the console when I click on "Wilton"

Let's say I have to replace the contents of the template storeTerritorywith plain HTML code, then a tooltip will appear:

<p>Wilton</p>

What could be the problem?

+4
source share
2 answers

The problem is the lack of a model associated with the tooltip; in order to do what you want, you need to create content using the function:

$("#grid").kendoTooltip({
    autoHide: true,
    showOn: "mouseenter",
    width: 125,
    height: 125,
    position: "right",
    filter: ".k-grid-content a.hasTooltip",
    content: function (e) {
        var row = $(e.target).closest("tr");
        var dataItem = $("#grid").data("kendoGrid").dataItem(row);

        var template = kendo.template($("#storeTerritory").html());
        return template(dataItem);
    }
});

( )

+5

, ( ):

<script type="text/x-kendo-template" id="storeTerritory">
    <div class="tooltipcontent">
        #if (Territories != 'null' && Territories != '')  {#
            <p>#=Territories[i].TerritoryDescription#</p>
        #} else{#
            <p>Information not available</p>
        #}#
    </div>
</script>

Territories i, .

0

Source: https://habr.com/ru/post/1537489/


All Articles