2015-02-11 18 views
5

मेरे कोड में क्या गलत है?केंडो ui ग्रिड अगर अन्यथा स्थिति

मुझे अपने कॉलम में केंडो यूआई ग्रिड में "ऑर्डर टाइप 20" है। यदि ऐसा है, तो मुझे अपनी सीएसएस स्थिति लागू करने की आवश्यकता है जिसमें पृष्ठभूमि शामिल है, लेकिन यह काम नहीं करता है, क्या कोई मेरी मदद कर सकता है? धन्यवाद

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

उत्तर

9

यह अगर नेस्टेड केन्डो ui ग्रिड पंक्ति टेम्पलेट के लिए किसी और के लिए आपकी मदद कर सकता है। यानी

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

आप इस बेला ग्रिड डेटाबाउंड घटना too.Check में इसे संभाल कर सकते हैं:

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

इसके बजाय आप सभी सेल संग्रह के माध्यम से पाशन के डेटाबाउंड संशोधित कर सकते हैं

if(dataItem.OrderType == 'OrderType20') 
3

मैं आपको एक फ़ंक्शन लिखने और टेम्पलेट में कॉल करने और उसमें तर्क को कोड करने की सलाह दूंगा। निम्नलिखित उदाहरण है।

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

आसान तरीका पर किया: धन्यवाद सभी

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

संबंधित मुद्दे