How can I use nested Json to populate Kendo UI grid?

后端 未结 2 681
轮回少年
轮回少年 2020-12-03 12:52

How can I populate Kendo UI grid with nested JSON.

I mean my JSON is like

var myJson:
    [{\"oneType\":[
        {\"id\":1,\"name\":\"John Doe\"},
          


        
2条回答
  •  春和景丽
    2020-12-03 13:17

    I just wanted to submit another answer based on OnaBai's.

    http://jsfiddle.net/L6LwW/17/

    The HTML:

    
    
    

    The JS:

    var grid = $("#grid").kendoGrid({
      dataSource: {
        data: [
          [{
            "id": 1,
            "name": "John Doe",
            "ddl": [{
              "key": 1,
              "value": "hello"
            }, {
              "key": 1,
              "value": "hello"
            }]
          }, {
            "id": 2,
            "name": "Don Joeh",
            "ddl": [{
              "key": 1,
              "value": "hello"
            }, {
              "key": 1,
              "value": "hello"
            }]
          }]
         ],
        pageSize: 10,
        schema: {
          parse: function(d) {
            for (var i = 0; i < d.length; i++) {
              if (d[i]) {
                return d[i];
              }
            }
            return [];
          }
        }
      },
      columns: [{
          field: "id",
          title: "ID"
        }, {
          field: "name",
          title: "Name"
        }, {
          field: "ddl",
          title: "DDL",
          width: "180px",
          template: kendo.template($("#message-template").html())
        } //template: "#=ddl.value#" }
      ]
    }).data("kendoGrid");
    

提交回复
热议问题