Kendo 工具提示为空

Kendo Tooltip is empty

d我在 kendo 网格的列的单元格上使用 kendo 工具提示,但工具提示的内容为空。 当我使用 chrome 调试器时,值设置正确但工具提示中没有任何内容。

    $("#gri").kendoTooltip({
        filter: "span.tooltip",
        position: "right",
        content: function (e) {
            var tooltipHtml;
            $.ajax({
                url: ".." + appBaseUrl + "api/Infobulle?id=" + $(e.target[0]).attr("id"),
                contentType: "application/json",
                dataType: "json",
                data: {},
                type: "GET",
                async: false
            }).done(function (data) {   // data.Result is a JSON object from the server with details for the row
                if (!data.HasErrors) {
                    var result = data.Data;
                    tooltipHtml = "Identifiant : " + result.identifiant;
                } else {
                    tooltipHtml = "Une erreur est survenue";
                }
                // set tooltip content here (done callback of the ajax req)
                e.sender.content.html(tooltipHtml);
            });
        }

有什么想法吗?为什么它是空的?

在 telerik 论坛上查看了开发人员的回答后,我发现您需要做类似

的事情
content: function(){
   var result = "";
   $.ajax({url: "https://jsonplaceholder.typicode.com/todos/1", async:false , success: function(response){
        result = response.title
   }});
   return result;
}

直接用e.sender.content.html()改变是行不通的,我们必须return这个值。我尝试了几种方法:

  1. 我尝试使用 setTimeOut 模拟 ajax 调用,return 在其中输入字符串或使用 e.sender.content.html() 将不起作用
  2. 我尝试使用 content.url(唯一的缺点是我仍然不知道如何修改响应,我显示了整个响应)
  3. 第三个我尝试使用 here
  4. 开发者的回答

并检查我在 dojo 中的示例 工作示例,将鼠标悬停在第三次尝试上