app.get('/Orders', (req, res) => {
// you can get the query from Grid by using “req.query”
if (data.length == 0) {
for (var i = 1; i < 6; i++) {
data.push({ OrderID: i, OrderDate: new Date(i), ShipCity: i % 2 == 0 ? 'Durban' : 'Sidney', ShipCountry: i % 2 == 0 ? 'SouthAfrica' : 'Australia' });
}
}
var resultArray = data;
res.send({ result: resultArray });
});
|
<template>
<div id="app">
<ejs-grid ref="grid" :load="load" :editSettings="editSettings" :toolbar="toolbar" :allowFiltering="true" :allowSorting="true" :allowPaging="true" :pageSettings="pageSettings">
<e-columns>
. . .
</e-columns>
</ejs-grid>
</div>
</template>
<script>
. . .
methods: {
load: function(e) {
// using dataManager to get the json from server
new DataManager({
url: "http://localhost:5000/Orders",
}).executeQuery(new Query()).then((e)=>{
this.$refs.grid.ej2Instances.dataSource = new DataManager({
json: e.actual.result, // set the json based on your response
adaptor: new RemoteSaveAdaptor(),
insertUrl:"http://localhost:5000/Insert",
updateUrl:"http://localhost:5000/Update",
removeUrl:"http://localhost:5000/Remove",
crossDomain: true
})
})
</script>
|