Dear support,
I have read all documentations :
but I am pretty desperate.
I am unable to make the DataStateChange and DataSourceChanged work/get triggered.
1/ I don't understand how the "dataSourceChanged" work. In the example of the documentation it is not declared on the grid's props, neither on the mounted method, as the dataStateChange
2/ When I click on the "add" button of my grid, get my custom modal and click on the submit button, nothing happend, nothing is triggered.
I would like to trigger the dataSourceChanged, and then if the "state" is "add", call an API fonction to store my new datas.
3/ Moreover, I really dont get how the "state" variable works. Where is the state.action intialized ? Like here :
dataSourceChanged: function (state) {
if (state.action === 'add') {
this.orderService.addRecord(state).subscribe(() => state.endEdit());
} else if (state.action === 'edit') {
this.orderService.updateRecord(state).subscribe(() => state.endEdit());
} else if (state.requestType === 'delete') {
this.orderService.deleteRecord(state).subscribe(() => state.endEdit());
}4/ Then How can I change the "save"/ cancel" button of the dialog wich is opened by the toolbar action from the grid ?
Is it possible to make them not visible ? or Change the name ?
Thank you in advance,
|
<template>
<ejs-grid ref="grid" :dataSource="data" :dataSourceChanged="dataSourceChanged" :dataStateChange="dataStateChange"></ejs-grid>
</template>
<script>
import Vue from "vue";
import { GridPlugin, Toolbar, Edit } from "@syncfusion/ej2-vue-grids";
import { getOrders, addOrder, updateOrder, deleteOrder } from "./orderService";
Vue.use(GridPlugin);
export default {
name: 'app',
data() {
...
},
methods: {
dataStateChange: function (state) {
...
},
dataSourceChanged: function (state) {
...
}
}
}
</script> |
Thank you for your answer.
I have a problem in the code, the "dataSource.json" file does not seem to be included anywhere in the App.vue, so I can't ahev any data in the grid.
Moreover, it seems like all the import needed are not present.
I have an error with the "dataSourceChanged" which is not included in the import, whereas in the following documentation : https://ej2.syncfusion.com/vue/documentation/grid/data-binding/
you have the " import { GridPlugin, DataStateChangeEventArgs, Sorts, Sort, Group, Page, DataResult, Toolbar, Edit } from "@syncfusion/ej2-vue-grids" import.
Is it possible to have an example with EVERYTHING that is needed ? Datasource , import, etc ...
So, instead of the zip file :
https://www.syncfusion.com/downloads/support/forum/166918/ze/GridCustomDataBinding722982509
Is it possible to have an online example like this one ?
Sample link: https://codesandbox.io/s/form-validation-forked-2263r?file=/src/App.vue
It is easier for me to check the code when it is already online, this way I am sure that evrything needed is included.
Moreover, can you please give me a full example of this : "The argument is accessed with the name ‘state’ in the documentation and it will return the corresponding action details from the source with which you can handle the action in your server and return back the response to the Grid. This case can be checked in the above shared sample for reference. "
=> I don't understand how I have to do that ? In your zip.file, the "action" attribute is not set in the orderService.ts file, so I don't know/can't see how to do it.
best regards :)
|
mounted() {
// Used vue mounted hook to send initial request for fetching data from server
let state = { skip: 0, take: 12 };
this.dataStateChange(state);
},
methods: {
dataStateChange: function (state) {
getOrders().then(gridData => {
...
});
},
} |
|
// get
export function getOrders() {
return fetch(baseUrl + "/orders").then(res => res.json()).then(data => {
// Response data is returned back
return data;
});
} |
|
<ejs-grid :dataSource="data" :dataStateChange="dataStateChange"></ejs-grid>
<script>
...
methods: {
dataStateChange: function (state) {
getOrders().then(gridData => {
this.data = gridData;
});
},
}
</script> |
|
import { GridPlugin, DataStateChangeEventArgs } from "@syncfusion/ej2-vue-grids";
methods: {
dataStateChange: function (state: DataStateChangeEventArgs) {
getOrders().then(gridData => {
this.data = gridData;
});
},
} |