Kendo ui grid if else condition

后端 未结 5 1241
春和景丽
春和景丽 2020-12-15 10:35

What is wrong with my code?

I have to check in kendo UI grid is there \"OrderType 20\" in my column. If it is, I need to apply my css condition which includes back

相关标签:
5条回答
  • 2020-12-15 10:58

    done on easier way: thank You all

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

    0 讨论(0)
  • 2020-12-15 10:59

    It might help you for nested if else for kendo ui grid row template. i.e.

    template: "#if(ErrorDesc==null){# #: DeviceLabel # #}else If(ErrorDesc==""){# #: DeviceLabel # #}else{# #: DeviceText # #}#"
    
    0 讨论(0)
  • 2020-12-15 11:00
    {
      field: "status",
      title: "Status",
      width: "80px",
      template: "#  if (status == '1' ) { # <center><span 
                    style='color:green;'>Active</span></center> #
                } 
                else if (status == '0'){ # 
                   <center><span style='color:red;'>Deactive</span></center> 
                #} #"
    }
    
    0 讨论(0)
  • 2020-12-15 11:05

    You can handle it in grid databound event too.Check this fiddle:

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

    You can modify the databound instead of looping through all the cell collection

    if(dataItem.OrderType == 'OrderType20')
    
    0 讨论(0)
  • 2020-12-15 11:24

    I would recommend you to write a function and call that in template and code the logic in that. following is the 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";
    }
    
    0 讨论(0)
提交回复
热议问题