javascript Kendo UI 窗口小部件 - 使用模板的动态标题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19827230/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Kendo UI Window widget - Dynamic title using templates
提问by nouptime
Is it possible to have dynamic window titles using templates?
是否可以使用模板获得动态窗口标题?
Something like this:
像这样的东西:
wnd = $("#details").kendoWindow({
title: #= ItemName #,
modal: true,
visible: false,
resizable: false,
width: 300}).data("kendoWindow");
I added ItemNamein the title field merely to indicate the concept. Any idea?
我在标题字段中添加了ItemName只是为了表明这个概念。任何的想法?
回答by Bishnu Rawal
You can do it with setOptionsapi method, something like:
您可以使用setOptionsapi 方法来完成,例如:
// Setting some options
wnd.setOptions({
title: "dynamic title",
width: "60%"
});
First initialize your window with your code and on some events (button click may be), use window object to set its options.
首先使用您的代码初始化您的窗口,并在某些事件(可能是按钮单击)上使用 window 对象设置其选项。
If its not clear, lets play with example: I am setting the window title on kendo-grid custom command button click:
如果不清楚,让我们玩一下例子:我在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>
回答by nouptime
This is easy way i have show event title in title header like that
这是我在标题标题中显示事件标题的简单方法
API.get('/Scheduler/GetEventDetailById', detailParams).then(function (data) {
$('.k-window-title').text(data.EventTitle);
});