如果KendoUI中的值为null,请设置占位符

时间:2015-08-12 09:57:26

标签: javascript jquery kendo-ui kendo-grid

以下带有下拉列表的Kendo网格。下拉列表 AccountCode 项目的形式为对象,如下所示;

enter image description here

以下用于显示详细信息;

    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"
        });
    }

显示时看起来像这样;

enter image description here

如果下拉对象为空,如何插入占位符,如第一张图片所示?试过通常的占位符标签,但它似乎没有用。

编辑:已添加代码

1 个答案:

答案 0 :(得分:1)

我非常确定这些字符串只是javascript代码。

"#:CostCenter.Description.length > 0 ? CostCenter.Description : 'placeholder'#"