質問

I am getting an issue while populating data in kendo drop down Please see my code and JSON response.

Code:

$("#sortOrder").kendoDropDownList({
        dataTextField: "SORTORDER",
        dataValueField: "SORTORDER",
        dataSource: {
            transport: {
                read: {
                    type: "POST",
                    dataType: "json",
                    url: "xyz.php",

                }
            }
        }
    });

JSON response : {"results":[{"SORTORDER":"1"},{"SORTORDER":"9"},{"SORTORDER":"5"},{"SORTORDER":"3"},{"SORTORDER":"4"},{"SORTORDER":"6"},{"SORTORDER":"7"},{"SORTORDER":"8"},{"SORTORDER":"10"},{"SORTORDER":"2"},{"SORTORDER":"0"}]}

Error : n.slice is not a function.

役に立ちましたか?

解決

The read operation expects an array, but you're giving it an object which has a property results which contains the array; either make your server return the array only, or define your read operation like this:

read: function (options) {
    $.ajax({
        url: "...",
        dataType: "json",
        type: "POST",
        success: function (data) {
            options.success(data.results);
        }
    });
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top