Kendo远程数据源和参数

问题描述 投票:0回答:1

我正在尝试调用read方法,但也要传递参数。下面是我的代码,可以看到正在传递值,但控制台中存在错误:

    var dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: URL + "/Read?StudentNum=" + studentNum + "AndStudentDept=" + studentDept,
                dataType: "json",
                data: {
                    studentNum: studentNum,
                    studentDept: studentDept
                }
            },
            pageSize: 5,
            schema: {
                data: function (response) {
                    console.log(response);
                    return response.Data.dsstudentReport.ttstudentReport;
                },
            }
        }
    });
The error is: kendo.all.js:7165 Uncaught TypeError: e.slice is not a function

I will continue to keep looking but if anyone could help me identify where I have made a mistake, that would be greatly appreciated. I am new to Kendo and still learning.


Thanks
jquery kendo-ui datasource kendo-asp.net-mvc
1个回答
1
投票

经常发生此错误,因为model中没有schema。尝试添加它。例如:

transport: {},
schema: {
        model: {
            id: "id",
            fields: {
                name: { type: "string" },
                isActive: { type: "boolean" },
                age: { type: "number" }
            }
        }
    }

它表示您正在使用read方法获取的数据结构。

Ps。 schema必须与transport处于同一级别。您的情况schema位于transport内部

© www.soinside.com 2019 - 2024. All rights reserved.