6

ネストされた JSON を使用して Kendo UI グリッドを設定するにはどうすればよいですか。

つまり、私のJSONは次のようなものです

var myJson:
    [{"oneType":[
        {"id":1,"name":"John Doe"},
        {"id":2,"name":"Don Joeh"}
    ]},
    {"othertype":"working"},
    {"otherstuff":"xyz"}]
}];

Id、Name、OtherType、OtherStuff の列を持つ Kendo UI Grid が必要です。

前もって感謝します。!

4

2 に答える 2

0

オナバイに基づいて別の回答を提出したかっただけです。

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

HTML:

<script id="message-template" type="text/x-kendo-template">
  #for (var i = 0; i
  < ddl.length; i++) {# <li><span>#=ddl[i].value#</li>
    #}#
    </script>

<div id="grid"></div>

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");
于 2015-12-18T20:39:48.893 に答える