Search code examples
jquerykendo-uidatasourcekendo-asp.net-mvc

Kendo remote datasource and parameters


I am trying to call the read method but also pass in parameters. Below is my code and I can see the values are being passed but there is an error in the console:

    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

Solution

  • This error often occurs because there is no model in schema. Try to add it. For eg:

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

    It represents data structure that you are fetching with read method.

    Ps. schema must be on same level as transport. In your case schema is inside transport