【问题标题】:Kendo grid read datasource with http post response剑道网格读取数据源与http post响应
【发布时间】:2016-04-21 05:14:56
【问题描述】:

我是 Kendo UI 的新手,我使用数据表来显示值,这是我的旧代码(正在运行):

$http.post("/reports/api/g3swmf/report", $scope.g3sWmf ).success(function(data){
    $scope.reportVal += " - " + data;
}).then(function (response){
    $scope.items=response.data;   
}

这里是剑道 UI 版本(不工作):

$scope.g3sGridOptions = {
    toolbar: ["excel"],
    excel: {
        allPages: true
    },
    dataSource: {
        type: "json",
        transport: {
        read: {
            url:("/reports/api/g3swmf/report", $scope.g3sWmf ),
            type: "post",
            dataType: "json"
        }
    },
    schema: {
        model: {
            fields: {
                poloCode: { type: "string" },
            }
        }
    }
}

【问题讨论】:

  • 请定义不工作
  • 无法到达 /reports/api/g3swmf/report 控制器并获取响应数据@The_Black_Smurf

标签: angularjs kendo-ui kendo-grid


【解决方案1】:

剑道的传输 url 应该是一个字符串。

url:"/reports/api/g3swmf/report"

它的处理方式与$http.post 不同。其实就是直接把read参数传给jquery.ajax。

有两种方法可以解决这个问题。

  1. 为您的传输使用字符串 url
  2. 将您的 transport.read 定义为一个函数。然后你就可以打电话给你自己的$http.post。如果您定义一个函数,请注意 kendo 将提供一个事件参数和一些回调方法,这些回调方法应该用于将数据发送回网格。

这是一个自定义读取示例:

read: function (readOptions) {
    $http.post("/reports/api/g3swmf/report", $scope.g3sWmf ).success(function(data){
        readOptions.success(data);
    })
}

详情请咨询kendo dataSource API documentation

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多