javascript - 将json数据绑定(bind)到kendo grid

标签 javascript json kendo-ui kendo-grid

我必须将 Web API(post)调用的结果绑定(bind)到剑道网格。结果格式为

{
  "Id": 121,
  "referenceId": 18222,
  "status": null,
  "message": "Completed"
}

API 调用是:

            read: {
                url: //url,
                type: "POST",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
            },
            parameterMap: function () {
                return JSON.stringify({ Active: false });
            }
        },
        schema: {
           data:'data'
        }

绑定(bind):

$("#grid").kendoGrid({

          dataSource: dataSource
           columns: [{
                        field: "Id",
                        title: "Id"
                    }]
});

但它不起作用。 :(

最佳答案

引用中使用kendo.all.min文件。

使用此数据源部分

schema: {
                  model: {
                       id: "Id",
                      fields: {                                      
                          Id: {  },
                          referenceId: { },
                          status: { },
                          message: {} 
                     }
                  }
              }

在网格端使用它

      $("#grid").kendoGrid({
          dataSource: [{
              "Id": 121,
              "referenceId": 18222,
              "status": "test",
              "message": "Completed"
          }],
          navigatable: true,
          pageable: true,
          height: 550,
          toolbar: ["create", "save", "cancel"],
          columns: [
               { field: "Id", title: "Unit Price" },
                { field: "referenceId", title: "Units In Stock" },
                { field: "status", width: 120 },
                { field: "message", width: 120 }
          ],
          editable: true
      });

关于javascript - 将json数据绑定(bind)到kendo grid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36982876/

相关文章:

javascript - Kendo 网格取消导致删除行

javascript - 无法使用 jQuery 和 AJAX 发送 POST 请求

javascript - 将 React PureComponent 重构为基于钩子(Hook)的功能组件

php - 将 3kb 的 json 存储在 cookie 中,作为服务器或数据库中的文件

ios - 无法在 App 中将 json 字符串插入到 sqlite

javascript - 如何将带有本地数据的组合框添加到kendo网格列模板

kendo-ui - Kendo Tabstrip 周围的蓝色边框

javascript - 如何在 JavaScript 中创建 Bokeh 颜色映射器?

javascript - arangodb难度教程: Node. js (io.js) 10分钟

c# - 在 StreamingAssetsPath 上读取和写入文件