Kendo ui grid if else

问题描述:

我的代码有什么问题?Kendo ui grid if else

我必须检查kendo UI网格是否有“OrderType 20”在我的专栏。 如果是这样,我需要应用我的CSS条件,其中包括背景,但它不工作,有人可以帮助我吗?感谢

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

它可以帮助您对嵌套的if else对剑道UI网格行模板。即

template: "#if(ErrorDesc==null){# #: DeviceLabel # #}else If(ErrorDesc==""){# #: DeviceLabel # #}else{# #: DeviceText # #}#" 

可以在网格数据绑定事件too.Check处理它这个小提琴:

http://jsfiddle.net/Sowjanya51/krszen9a/

您可以修改的,而不是通过所有的细胞采集循环数据绑定

if(dataItem.OrderType == 'OrderType20') 

我建议你编写一个函数,然后在模板中调用它,然后编写这个逻辑。以下是例子。

$(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"; 
} 

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

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