Search code examples
kendo-uikendo-combobox

Kendo UI DataSource is breaking on ajax call "this.substr is not a function"


I'm getting the error:

Uncaught TypeError: this.substr is not a function
String.remove   @   vendor?v=aDfyqYhlmP6LIh14D-zVAUS28dc7bUxpraoGG0oruGc1:formatted:25867
e               @   vendor?v=aDfyqYhlmP6LIh14D-zVAUS28dc7bUxpraoGG0oruGc1:formatted:3465
ci              @   vendor?v=aDfyqYhlmP6LIh14D-zVAUS28dc7bUxpraoGG0oruGc1:formatted:249
i.param         @   vendor?v=aDfyqYhlmP6LIh14D-zVAUS28dc7bUxpraoGG0oruGc1:formatted:3475
ajax            @   vendor?v=aDfyqYhlmP6LIh14D-zVAUS28dc7bUxpraoGG0oruGc1:formatted:3668
read            @   kendo.all.min.js:11
(anonymous function)    @   kendo.all.min.js:11
_queueRequest   @   kendo.all.min.js:11
read            @   kendo.all.min.j

I realize that's not super helpful. This is what the transport object looks like:

var dataSource = {
    transport: {
        read: {
            type: 'POST',
            url: ajaxUrlFn(), //returns string
            dataType: 'application/json; charset=UTF-8',
            data: self.searchJson(), //returns string
        },
        schema: {
            data: function (response) {
                //code stuff...
            },
        },
    },
};

This will hit the read object and then break.


Solution

  • It seems as though the transport.read.data property is expecting an object type rather than a string type.

    var dataSource = {
        transport: {
            read: {
                type: 'POST',
                url: ajaxUrlFn(), //returns string
                dataType: 'application/json; charset=UTF-8',
    ----------->data: self.searchObject() //returns an object <-----------
            },
            schema: {
                data: function (response) {
                    //code stuff...
                },
            },
        },
    };