Kendo UI 数据网格:如何根据状态标志整数值更改列显示值

Kendo UI data grid: How to change column display value based on status flag integer value

在我的 datasource 中,status 的值为 01。基于此,在数据网格中我想将 Status 的值显示为 "Active for Status=1" and "Inactive for Status=0"。如何相应地修改列值。

这是我的数据网格的 DEMO

代码:

$(document).ready(function() {

          var myData = [{
            id: 1,
            name: "Grant",
            location: "A",
            color: "green",
            status: 1,
          }, {
            id: 2,
            name: "Vaughan",
            location: "B",
            color: "red",
            status: 0,
          }, {
            id: 3,
            name: "David",
            location: "A",
            color: "orange",
            status: 1,
          }];

          $("#grid").kendoGrid({
            dataSource: {
              data: myData,
              schema: {
                model: {
                  fields: {
                    id: { type: "number" },
                    name: { type: "string" },
                    location: { type: "string" },
                    color: { type: "string" }
                  }
                }
              }
            },
            columns: [
              { field: "id", title: "ID", width: "130px" },
              { field: "name", title: "Name", width: "130px" },
              { field: "location", title: "Location", width: "130px" },
              { field: "color", title: "Color", width: "130px" },
              { field: "status", title: "Status", width: "130px" },
            ]
          });


        });

为条件列值使用模板

{ field: "status", title: "Status", width: "130px", template: "#if(status==1) #  Active # }else{#  Inactive  #}#"}

Working fiddle