|
var promise=this.dataManager.executeQuery(new ej.Query().addParams('$top', '7'));
promise.done(function (e) {
ej.parseJSON(e.result); //parse the data to json object
});
} |
|
this.dataManager = new DataManager({ url: 'http://services.odata.org/V4/Northwind/Northwind.svc/Orders', adaptor: new ODataV4Adaptor }); |
|
this.dataManager = ej.DataManager({ url: 'http://services.odata.org/V4/Northwind/Northwind.svc/Orders', adaptor:"ODataV4Adaptor" });
this.gridData = this.dataManager; |
Hi,
thanks for the hint on the parameter, i once started with this example:
https://help.syncfusion.com/js/datamanager/data-binding with WebApiAdaptor an in this doc example the adaptor Parameter is not passed as a string. I just modified this starting snipped then.
Unfortunately I get a Cannot find name 'ej' error now.
Fixed the obove error with adding a reference of "@types/ej.web.all" to the types property in the tsconfig.json
Hi,
the ReferenceError: ej is not defined is back but I can't find out where i'm missing a piece.
Error:
restapi-adaptor.ts:6 Uncaught ReferenceError: ej is not defined
at Object.<anonymous> (restapi-adaptor.ts:6)
at __webpack_require__ (bootstrap 6fe175e14e9077501c5f:657)
at fn (bootstrap 6fe175e14e9077501c5f:85)
at Object.<anonymous> (navmenu.component.ts:15)
at __webpack_require__ (bootstrap 6fe175e14e9077501c5f:657)
at fn (bootstrap 6fe175e14e9077501c5f:85)
at Object.<anonymous> (app.module.browser.ts:31)
at __webpack_require__ (bootstrap 6fe175e14e9077501c5f:657)
at fn (bootstrap 6fe175e14e9077501c5f:85)
at Object.<anonymous> (index.js:4)
this is my Code in restapi-adaptor.ts
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
export class RestApiAdaptor extends ej.ODataV4Adaptor {
processQuery(dm: ej.DataManager, query: ej.Query, hierarchyFilters?: any): any {
// rewrite query string from orginal adapter
let original = super.processQuery.apply(this, arguments);
console.log(original);
let url = original.url;
url = url.replace('?$count=', '?count=');
url = url.replace('&$count=', '&count=');
url = url.replace('?$skip=', '?skip=');
url = url.replace('&$skip=', '&skip=');
url = url.replace('?$top=', '?top=');
url = url.replace('&$top=', '&top=');
return {
type: original.type,
url: url,
ejPvtData: original.ejPvtData,
contentType: original.contentType,
data: original.data
};
}
}
Fixed again, had to put the EJAngular2Module reference in app.module.shared.ts before the component holding the grid / loading the adaptor.