Greed does not show data with custom Adaptor (Cannot read property '0' of undefined)
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 ?
SIGN IN To post a reply.
3 Replies
RU
Ragavee U S
Syncfusion Team
March 22, 2016 11:22 AM UTC
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.
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.
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.
MI
Milos
March 22, 2016 11:40 AM UTC
Thank you so much. It works perfectly.
RU
Ragavee U S
Syncfusion Team
March 23, 2016 04:27 AM UTC
Hi Milos,
Thanks for your update.
We are happy that your issue is resolved.
Regards,
Ragavee U S.
Thanks for your update.
We are happy that your issue is resolved.
Regards,
Ragavee U S.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
MI Milos
- Mar 21, 2016 02:40 PM UTC
- Mar 23, 2016 04:27 AM UTC