剑道 UI 窗口小部件 - 使用模板的动态标题

Kendo UI Window widget - Dynamic title using templates

本文关键字:动态 标题 窗口 UI 小部 剑道      更新时间:2023-09-26

是否可以使用模板获得动态窗口标题?

像这样:

wnd = $("#details").kendoWindow({
 title: #= ItemName #,
 modal: true,
 visible: false,
 resizable: false,
 width: 300}).data("kendoWindow");

我在标题字段中添加了 ItemName 只是为了指示概念。知道吗?

你可以用setOptions api方法做到这一点,比如:

// Setting some options
wnd.setOptions({
    title: "dynamic title",
    width: "60%"
});

首先用你的代码初始化你的窗口,在某些事件上(按钮点击可能是),使用窗口对象来设置其选项。

如果不清楚,让我们玩一个例子:我正在设置kendo-grid自定义命令按钮单击的窗口标题:

<div class="k-content">
    <div id="noteswindow"></div>
</div>
<script>
$(document).ready(function () {
   $("#noteswindow")
        .kendoWindow({
            actions: ["Refresh", "Maximize", "Minimize", "Close"],            
            visible: false
        })   
});
function onNotesClick(e) {  // Custom button click
    e.preventDefault();
    var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
    rData = dataItem;
    // Using same window variable again and again for successive clicks with dynamic content
    var nWin = $("#noteswindow").data("kendoWindow");
    // Setting some options
    nWin.setOptions({
        title: "Notes on " + dataItem.AssetOrShotName,
        width: "60%"
    });
    nWin.refresh({
        url: "../Task/Notes",
        data: { AssignId: rData.Id }
    });
    nWin.open().center();    
}
</script>

这是我在标题标题中显示事件标题的简单方法

  API.get('/Scheduler/GetEventDetailById', detailParams).then(function (data) {
         $('.k-window-title').text(data.EventTitle);
  });