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

kendo endWith conflict with ScriptManager JS script

1 Answer 39 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dean
Top achievements
Rank 1
Dean asked on 04 Sep 2013, 09:37 AM
Hello

I have script manager in my page and am using kendoGrid. I am connecting the grid to the service. When this code runs I get the following error:
SCRIPT5007: Unable to get property 'length' of undefined or null reference
ScriptResource.axd, line 5 character 5907
I've checked the script manager code it is with the endWith, (String.prototype.endsWith=function(a){return this.substr(this.length-a.length)===a})

Thank you for your help
Below is the script used
 
$(document).ready(function () { Sys.Application.add_load(initContactsPage); });
var contactsGrid = null;
function initContactsPage()
{
    var contactsColumns = [{
        field: "CustomerName",
        title: "Name",
        template: '<a class="name" href="ContactDetails.aspx?Id=#=CustomerID#">#=CustomerName#</a>'
    },
    {
        field: "strCustomerNumber",
        title: "Number"
    },
    {
        field: "strMainPhone",
        title: "Phone"
    },
    {
        field: "strCity",
        title: "City"
    },
    {
        field: "strWebsite",
        title: "Web Site"
    }
    ];
    contactsGrid = $("#gvContacts").kendoGrid({
        columns: contactsColumns,
        dataSource: new kendo.data.DataSource({
            pageSize: 10, serverPaging: true, page: 1,
            schema:
                {
                    total: "VirtualTotal",
                    data: "Records"
                },
            transport:
                {
                    read:
                    {
                        url: "/Services/APIService.asmx/ListObjectRecords",
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        data: getData()
                    }
                },
            error: function (e)
            {
 
            }
        }),
        groupable: false,
        scrollable: false,
        pageable: true
    }).data("kendoGrid");
}
function searchContacts(page)
{
    contactsGrid.dataSource.page(1);
}
function getData()
{
    var contactsParams = {};
    contactsParams["objectId"] = "C9D9AEC9-F6C2-4EB3-8F00-D32A45A7C4C7";
    contactsParams["textFilter"] = null;
    contactsParams["sortColumn"] = null;
    contactsParams["startIndex"] = 1;
    contactsParams["pageSize"] = 10;
    return JSON.stringify(contactsParams);
}

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 06 Sep 2013, 08:36 AM
Hello David,

I believe that the problem is connected with dataSource's schema. ASMX services return JSON in the following format { "d": <result> } so you should configure the schema in the following way:
schema: {
    data: "d.Data", // ASMX services return JSON in the following format { "d": <result> }. Specify how to get the result.
    total: "d.Total",
    model: { // define the model of the data source. Required for validation and property types.
        //http://docs.kendoui.com/api/framework/datasource#configuration-schema.model
    }
},

There is also a sample project which demonstrates Grid bound to Web Service data CRUD operations. You can download it from here:
I hope this will help.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Discussions
Asked by
Dean
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or