繁体   English   中英

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" 我如何相应地修改列值。

这是我的数据网格的演示

码:

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

工作提琴

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM