我有一个Kendo UI Grid,可以在创建新记录或编辑现有记录时加载弹出窗口。
我正在努力寻找一种方法,在我创建新记录时将更新按钮的文本更改为“保存”(目前显示为“更新” - 并且不正确)。
我能够更改弹出窗口的标题,但我的问题是:如何更改按钮文字?
这是代码:
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
sortable: true,
groupable: true,
height: resizeGrid(),
filterable: true,
toolbar: ["create"],
columns: [
{ field: "OfficeName", title: "Office Name" },
{ field: "SupportNo", title: "Phone No.", width: "100px" },
{ field: "SupportEmail", title: "Email Address", width: "130px" },
{ field: "SupportFax", title: "Fax No.", width: "100px" },
{ field: "SupportFtp", title: "Ftp Url", width: "150px" },
{ command: ["edit", "destroy"], title: "Actions", width: "160px" }],
editable: "popup",
edit: function (e) {
var editWindow = e.container.data("kendoWindow");
if (e.model.isNew()) {
e.container.data("kendoWindow").title('Add New Office');
$(".k-grid-update").text = "Save";
}
else {
e.container.data("kendoWindow").title('Edit Office');
}
}
});
答案 0 :(得分:18)
您应该将command
定义为:
command: [
{
name: "edit",
text: {
edit: "Edit", // This is the localization for Edit button
update: "Save", // This is the localization for Update button
cancel: "Cancel changes" // This is the localization for Cancel button
}
},
{
name: "destroy",
text: "Delete Office" // This is the localization for Delete button
}
]
此外,如果您还想在弹出窗口中更改文本Edit
,则应使用:
editable : {
mode : "popup",
window : {
title: "Edit Office", // Localization for Edit in the popup window
}
}
答案 1 :(得分:6)
这将更新 PopUp Editor 按钮中的文本:
if (e.model.isNew()) {
$("a.k-grid-update")[0].innerHTML = "<span class='k-icon k-update'></span>Activate";
}
else {
$("a.k-grid-update")[0].innerHTML = "<span class='k-icon k-update'></span>Save";
}
答案 2 :(得分:1)
edit: function (e) {
if (e.model.isNew()) {
$(".k-window-title")[0].innerHTML = "Add";
}
}