We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Greed does not show data with custom Adaptor (Cannot read property '0' of undefined)

Thread ID:

Created:

Updated:

Platform:

Replies:

123478 Mar 21,2016 10:40 AM Mar 23,2016 12:27 AM JavaScript 3
loading
Tags: ejmGrid
Milos
Asked On March 21, 2016 10:40 AM

I made my custom adaptor:

var customAdaptor = new ej.UrlAdaptor().extend({
        processResponse: function (data, ds, query, xhr, request, changes) {
            // here is some logik for preparig data
            return {
                             count: dataCount,
                             data: preparedData
                       };
        },

        processQuery: function (dm, query, hierarchyFilters) {
            return {
                url: "https://services/.../service1.svc/GetFetchXMLResponse",
                async: true,
                type: "POST",
                dataType: 'json',
                contentType: "application/json",
                data: fetchXMLData,
            }
        }
    });

This is the code where I provide my custom adopter to grid data manager. URL below is unimportant because in "processQuery" method in my custom adaptor I always change call to some other service.

var dataManager = ej.DataManager({
url:"http://mvc.syncfusion.com/Services/Northwnd.svc/Foods",
adaptor: new customAdaptor()
});

    $("#grid").ejGrid({
            dataSource: dataManager,
    });

This code causes error in console: "Cannot read property '0' of undefined".
I do not understand what I am doing wrong. Line "61551" in ej.web.all.js file make a problem beacuse "this.model.currentViewData" is undefined. Line is below:

for (this._gridRecordsCount ? this._initColumns(this.model.currentViewData[0] != r ? this.model.currentViewData[0] : this.model.currentViewData.value) : this._isLocalData && (this._dataSource() != null  && this._dataSource().length || this._dataManager && this._dataManager.dataSource.json.length) && this._initColumns(this._dataSource()[0] != r ? this._dataSource()[0] : this._dataManager.dataSource.json[0]),

Any help please ?

Ragavee U S [Syncfusion]
Replied On March 22, 2016 07:22 AM

Hi Milos,

We have analyzed the reported query. The cause of the issue is that the data from processResponse function of the customAdaptor has been returned incorrectly.

The return type in processResponse method should be in result and count format but not data and count format. Please refer to the code example.

var customAdaptor = new ej.UrlAdaptor().extend({

            processResponse: function (data, ds, query, xhr, request, changes) {

               

                return {

                    count: dataCount,

                    result: preparedData

                };

            },

           
        });


For your convenience, we have created a sample which can be downloaded from the below location.

Sample Link: http://www.syncfusion.com/downloads/support/forum/123478/ze/Sample1315013428

Regards,
Ragavee U S.

Milos
Replied On March 22, 2016 07:40 AM

Thank you so much. It works perfectly.

Ragavee U S [Syncfusion]
Replied On March 23, 2016 12:27 AM

Hi Milos,

Thanks for your update.

We are happy that your issue is resolved.

Regards,
Ragavee U S.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;