如果 KendoUI 中的值为 null,则设置占位符
Set a Placeholder if the Value is null in KendoUI
下面的 Kendo 网格带有下拉菜单。下拉列表 AccountCode 项的形式如下所示;
下面用来显示详情;
function loadGrid() {
$("#grdItems").kendoGrid({
dataSource: itemDS,
pageable: {
refresh: false,
pageSizes: false
},
aggregate: [{ field: "Amount", aggregate: "sum" }],
columns: [ {
field: "CostCenter",
title: "Cost Center",
editor: costCenterDropDownEditor,
template: "#:CostCenter.Description#"
}, {
field: "AccountCode",
title: "Account Code",
editor: accountDropDownEditor,
template: "#AccountCode.AccountDescription#"
}, {
field: "Description",
}, {
field: "BillNumber",
title: "Bill Number",
},
{
field: "Amount",
format: "{0:n}",
footerTemplate: "Sum: #= kendo.toString(sum, 'n')#"
},
{ command: [{ name: "edit", text: "MODIFY" }], title: " ", width: "120px" }],
editable: "popup"
});
}
显示时是这样的;
如第一张图片所示,当下拉对象为空时如何插入占位符?尝试了通常的占位符标记,但它似乎不起作用。
编辑:添加代码
我很确定这些字符串只是 javascript 代码。
"#:CostCenter.Description.length > 0 ? CostCenter.Description : 'placeholder'#"
下面的 Kendo 网格带有下拉菜单。下拉列表 AccountCode 项的形式如下所示;
下面用来显示详情;
function loadGrid() {
$("#grdItems").kendoGrid({
dataSource: itemDS,
pageable: {
refresh: false,
pageSizes: false
},
aggregate: [{ field: "Amount", aggregate: "sum" }],
columns: [ {
field: "CostCenter",
title: "Cost Center",
editor: costCenterDropDownEditor,
template: "#:CostCenter.Description#"
}, {
field: "AccountCode",
title: "Account Code",
editor: accountDropDownEditor,
template: "#AccountCode.AccountDescription#"
}, {
field: "Description",
}, {
field: "BillNumber",
title: "Bill Number",
},
{
field: "Amount",
format: "{0:n}",
footerTemplate: "Sum: #= kendo.toString(sum, 'n')#"
},
{ command: [{ name: "edit", text: "MODIFY" }], title: " ", width: "120px" }],
editable: "popup"
});
}
显示时是这样的;
如第一张图片所示,当下拉对象为空时如何插入占位符?尝试了通常的占位符标记,但它似乎不起作用。
编辑:添加代码
我很确定这些字符串只是 javascript 代码。
"#:CostCenter.Description.length > 0 ? CostCenter.Description : 'placeholder'#"