Kendo ui grid if other condition

What is wrong with my code?

I need to check the kendo user interface grid, there is "OrderType 20" in my column. If so, I need to apply my css condition, which contains the background, but it does not work, can someone help me? thanks

template: '# if (OrderType == "OrderType 20") {#<div class='customClass'>#:OrderType#</div>#} else {#OrderType#}#' 
+5
source share
4 answers

This may help you for a nested if else for the kendo ui grid line template. i.e.

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

make it easier: thank you all

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

I would recommend you write a function and call it in a template and encode the logic in it. The following is an example.

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

You can also handle it in a grid-bound event. Check out this script:

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

You can change the data binding instead of iterating over the entire collection of cells

 if(dataItem.OrderType == 'OrderType20') 
+1
source

Source: https://habr.com/ru/post/1213152/


All Articles