This is a migrated thread and some comments may be shown as answers.

Error: Unable to get property 'toLowerCase'

2 Answers 1210 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Keith
Top achievements
Rank 1
Keith asked on 17 Nov 2013, 10:46 PM
Browser: Internet Explorer 10 (although it occurs in all browsers)
Kendo UI v2013.2.716
jQuery: as Included in trial download

SCRIPT5007: Unable to get property 'toLowerCase' of undefined or null reference
kendo.all.min.js, line 13 character 1431

's' is undefined.


This error happens whenever I call dataSource.read(), and after the service successfully returns a response with a result in it.

Here's how I have my DataSource setup, tied to a Grid widget:


var myDataSource = new kendo.data.DataSource({
    transport: {
        create:{
            dataType: "json",
            url: CREATE_CONTACT,//Global var equal to service uri to call for this operation
            type: "POST",
            async:false
        },
        read: {
            dataType: "json",
            url: RETRIEVE_CONTACTS,//Global var equal to service uri to call for this operation
            type: "POST",
            async:false,
            success:function(response){
                //This is never being called.
                // Error occurs whether I include a "success" method or not.
                return response;
            },
            error:function(jqxhr){
                //This is never being called.
                // Error occurs whether I include a "success" method or not.
                errorMsgDlg("Read Error","Error Reading Grid", jqxhr);
            }
        },
        update:{
            dataType: "json",
            url: UPDATE_CONTACT,//Global var equal to service uri to call for this operation
            type: "POST",
            async:false
        },
        destroy:{
            dataType: "json",
            url: DELETE_CONTACT,
            type: "POST",
            async:false
        },
        parameterMap: function(data, type) {

            var contactGroupID = viewModel.get("contactGroupID"),
                contactGroupID = contactGroupID.toJSON(),
                parameters;

            if (type == "create") {

                parameters = {
                    contactGroupID: JSON.stringify(contactGroupID) || "",
                    models: kendo.stringify(data.models) || ""
                };
            }
            else if (type == "read") {
                parameters = {
                    contactGroupID: JSON.stringify(contactGroupID) || ""
                };
            }
            else if (type == "update") {
                parameters = {
                    contactGroupID: JSON.stringify(contactGroupID) || "",
                    models: kendo.stringify(data.models) || ""
                };
            }
            else if (type == "destroy") {
                parameters = {
                    contactGroupID: JSON.stringify(contactGroupID) || "",
                    models: kendo.stringify(data.models) || ""
                };
            }
            return parameters || {};
        }
    },
    schema: {
        parse:function(response){
             //Never see this get called
            return response;
        },
        model: {
            id: "name",
            fields: {
                name: { type: "string" },
                email: { type: "string" },
                organization: { type: "string" },
                type: { type: "string" }
            }
        }
        ,data: function(response){

            //Never see this get called
            return response;//Should be an array of contacts
        }
     }
});

$("#mygrid").kendoGrid({
    scrollable: true,
    dataSource: myDataSource,
    columns: [
        {
            field:"name",
            title: "POC Name"
        },
        {
            field:"email",
            title: "Email"
        },
        {
            field:"organization",
            title: "Organization"
        },
        {
            field:"type",
            title: "Type"
        }
    ],
    change:function(e){

        //I'm not seeing this get called.
        var dataItem = this.dataItem() || this.dataItem(e.item.index()) || {},
            name = dataItem.name || "",
            email = dataItem.email || "",
            organization = dataItem.organization || "",
            type = dataItem.type || "Action";
        
        /*Do stuff*/
    }
});

/*
This function is activated when a user selects an item to load.
function MyOnLoadFunction(){

    /*
    snip - setting data in viewModel with kendo MVVM
    
    */
    var MyGrid = $("#mygrid").data("kendoGrid");
    MyGrid.dataSource.read();//Happens during this call, but after the service returns
    MyGrid.refresh();
    
    /*snip other loading stuff*/
}





/*snip HTML stuff*/
<div id="mygrid"></div>
/*snip more html*/



2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 18 Nov 2013, 08:22 AM
Hello Keith,

 This error could happen if there is a problem while the data source tries to parse the server response. You can try commenting out parts of the data source declaration to see if this would make any difference. If you need further assistance please paste here what the server response is so we can troubleshoot.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Keith
Top achievements
Rank 1
answered on 18 Nov 2013, 03:48 PM
Thanks for the reply. I was able to find the problem.

It actually had to do with some bad script imports in the main html file. Originally, it had been importing just the core script and each sub widget being used, but later the "kendo.all.min.js" script was added somewhere in the middle of all the imports.

After deleting every kendo <script> in the header, but the one for "kendo.all.min.js", the problem went away.
Tags
Data Source
Asked by
Keith
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Keith
Top achievements
Rank 1
Share this question
or