如果其他条件,剑道ui网格

Avi*_*tor 8 javascript conditional if-statement kendo-grid

我的代码出了什么问题?

我必须检查kendo UI网格我的列中是否有"OrderType 20".如果是,我需要应用我的css条件,其中包括背景,但它不起作用,有人可以帮助我吗?谢谢

template: '# if (OrderType == "OrderType 20") {#<div class='customClass'>#:OrderType#</div>#} else {#OrderType#}#'
Run Code Online (Sandbox Code Playgroud)

Ani*_*ngh 18

它可能会帮助您嵌套if else for kendo ui网格行模板.即

template: "#if(ErrorDesc==null){# #: DeviceLabel # #}else If(ErrorDesc==""){# #: DeviceLabel # #}else{# #: DeviceText # #}#"
Run Code Online (Sandbox Code Playgroud)


ash*_*ale 6

我建议您编写一个函数并在模板中调用它并在其中编写逻辑。以下是示例。

$(gridId).kendoGrid({
dataSource: {
    data: datasource
},
scrollable: true,
sortable: true,
resizable: true,
columns: [
 { field: "MetricName", title: "Metric", width: "130px" },
 { field: "OnTrack", title: "On Track", template:'#:changeTemplate(OnTrack)#', width: "130px", attributes: { style: "text-align: center !important;" } },
 { field: "CurrentAmount", title: "Current", template: '$ #:parseFloat(CurrentAmount).toFixed(2)#', width: "130px" },
 { field: "RequiredAmount", title: "Required", template: '$ #:parseFloat(RequiredAmount).toFixed(2)#', width: "130px" }
]
});

function changeTemplate(value)
{
   Conditions depending on Your Business Logic
if ()
    return "HTML Here";
else
    return "HTML Here";
}
Run Code Online (Sandbox Code Playgroud)


Avi*_*tor 6

以更简单的方式完成:谢谢大家

template: "#if(OrderType == 'OrderType 20') {#<div class='customClass'>#:OrderType#</div>#} else{##:OrderType##}#"
Run Code Online (Sandbox Code Playgroud)