Dear support,
In order to create new items, I would Like to include a form in a dialog.
When I click on the submit button of the form, I would like the dialog to be closed, and the form to get submitted.
How can I do ?
best regards
<template>
<div>
<div id="target"
class="control-section; position:relative"
style="height: 600px">
<!-- Render Button to open the Dialog -->
<ejs-button id="modalBtn" v-on:click.native="btnClick">Open Dialog</ejs-button>
<!-- Render Dialog -->
<ejs-dialog id="dialog"
ref="templateDialog"
:target="target"
:height="height"
:width="width"
:visible="false"
:allowDragging="true"
header="Dialog Form"
:showCloseIcon="true">
<div class="container">
<form>
<div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
</div>
</div>
<div class="form-group">
<label>Input: </label>
<input />
</div>
<br />
<ejs-button id="modalBtn1" v-on:click.native="submitBtnClick">Submit</ejs-button>
</form>
</div>
</ejs-dialog>
</div>
</div>
</template>
<script>
. . .
. . .
export default {
. . .
. . .
methods: {
btnClick: function () {
this.$refs.templateDialog.show();
},
submitBtnClick: function () {
//dialog is closed by calling hide method.
this.$refs.templateDialog.hide();
// submit button action functionalities can be written here.
},
},
};
</script> |
Dear support,
Thank you for the answer, but is not exactly what I want.
I can already close the dialog.
My main problem is that when I click on the submit button, is does not submit the form.
In fact, here is the whole thing :
=> I have a page, with a list of items and an "add" button.
=> When you click on the "add" button, it opens a dialog, with a form to create a new item
Here is what I want :
1/ When I click the "submit" button inside the dialog, I want the dialog form to get submitted so as to create my new item
2/ Then, the dialog must be closed
3/ At last, the list of items must be refreshed to shows the new item inside of it, WITHOUT a complete page refresh.
(Juste the content of the page must be refresh).
Here is the code :
- The list.vue where you can see the list of items and the "add button"
- the Create.vue which contains the dialog
<template>
<div>
<div id="target"
class="control-section; position:relative"
style="height: 600px">
<!-- Render Button to open the Dialog -->
<ejs-button id="modalBtn" v-on:click.native="btnClick">Add</ejs-button>
<!-- Render Dialog -->
<ejs-dialog id="dialog"
ref="templateDialog"
:target="target"
:height="height"
:width="width"
:visible="false"
:allowDragging="true"
:content="contentTemplate(horseCollection)"
header="Dialog Form"
:showCloseIcon="true">
</ejs-dialog>
<hr />
<table style="width: 100%" id="table">
<tr>
<th>Name</th>
<th>Mail</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</div>
</div>
</template>
<script>
. . .
. . .
export default {
data: function () {
return {
target: "#target",
height: "100%",
width: "435px",
contentTemplate: function () {
return () => {
return {
template: {
extends: contentTemplate,
propsData: {
horseCollection: [],
},
},
};
};
},
};
},
methods: {
btnClick: function () {
this.$refs.templateDialog.show();
},
submitBtnClickHandler: function (Name, Mail) {
var tableRow = document.createElement('tr');
var td1 = document.createElement('td');
var td2 = document.createElement('td');
tableRow.appendChild(td1);
tableRow.appendChild(td2);
var tab = document.getElementById('table');
tab.appendChild(tableRow);
td1.innerHTML = Name;
td2.innerHTML = Mail;
//dialog is closed by calling hide method.
this.$refs.templateDialog.hide();
// submit button action functionalities can be written here.
},
},
};
</script> |
<template>
<div>
<div class="container">
<form>
<div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<br />
<hr />
<br />
</div>
</div>
<div class="form-group">
<label>Name: </label>
<input id="input1" ref="name" />
</div>
<br />
<div class="form-group">
<label>Mail: </label>
<input id="input2" ref="mail" />
</div>
<br />
<ejs-button type="button"
id="modalBtn1"
v-on:click.native="submitBtnClick">Submit</ejs-button>
</form>
</div>
</div>
</template>
<script>
export default {
name: "contentTemplate",
props: ["horseCollection", "submitBtnClickHandler"],
methods: {
submitBtnClick: function () {
var Name = this.$refs.name.value;
var Mail = this.$refs.mail.value;
this.$parent.$parent.submitBtnClickHandler(Name, Mail);
//dialog is closed by calling hide method.
// submit button action functionalities can be written here.
},
},
};
</script> |
Thank you very much .
I think this is exactly what I need. However, I have a mistake when I try to execute the code :
"[Vue warn]: Error in created hook: "ReferenceError: submitBtnClickHandler is not defined".
I checked so as to see if I forgot something, but I don't see anything wrong.
Is there any import I need to do to make the " submitBtnClickHandler " work ?
=> Can you check my code and tell me what is wrong ? .
Moreover, I forgot to tell you something :
In fact, the list where I want to show the new created item is not exactly a "list", this is a grid, an "<ejs-grid>" one.
=> Can you show me how to refresh a grid with a new item is created ?
Thank you very much in advance !
export default {
name: "contentTemplate",
props: ["horseCollection", "submitBtnClickHandler"],
} |
submitBtnClickHandler: function (Id, Name) {
//form data
var d = {
CustomerID: Id,
CustomerName: Name,
};
this.$refs.grid.ej2Instances.addRecord(d, 0); // update the form data into the Grid by using Grid’s addRecord method
this.$refs.templateDialog.hide();
}, |
Thank you for your answer.
I changed the props, but new there is a new error :
"TypeError: this.$parent.$parent.submitBtnClickHandler is not a function"
My code is in the zipFile.
Thank you very much for your help
Dear support,
I found the solution :)
I replaced :
By :
I've got one last question :
In fact, when I submit my item datas thanks to my dialog form, I would like to :
- Use a webservice(API) to save the submitted datas in a mysql database
- Refresh the content of the whole grid so as to include previous and brand news datas
=> I don't want to just add a temporary line with submitted datas that would disappear if I refresh the whole page.
I really need to populate the grid with all Mysql datas, because it needs to show, for instance, to retrieve the brand new primary key created in the Mysql database (just after form submission) for the new item.
- Then Close the form dialog
Can you help me ?
Thank you in advance !
Thank you, I am gong to check all the documentations and tell you if it works for me.
In the https://ej2.syncfusion.com/vue/documentation/grid/data-binding/?_ga=2.110355269.1969696766.1625244187-2053838237.1623261141#custom-binding documentation, , "
Perform CRUD operations", you have this :
<template>
<div id="app">
<ejs-grid :dataSource='data' :allowPaging='true' :pageSettings='pageOptions' :allowSorting='true' :allowGrouping='true' :dataStateChange='dataStateChange' :editSettings='editSettings' :toolbar='toolbar'>
<e-columns>
<e-column field= "OrderID" headerText="Order ID" :isPrimaryKey='true' width="130" textAlign='Right' >e-column>
<e-column field= "CustomerID" headerText="Customer Name" width="150">e-column>
<e-column field= "ShipName" headerText="Ship Name" width="200">e-column>
<e-column field= "ShipCity" headerText="Ship City" width="150">e-column>
e-columns>
ejs-grid>
div>
template>
<script>
import Vue from "vue";
import { GridPlugin, DataStateChangeEventArgs, Sorts, Sort, Group, Page, DataResult, Toolbar, Edit } from "@syncfusion/ej2-vue-grids";
import { OrderService } from "./order-service";
Vue.use(GridPlugin);
export default Vue.extend({
data() {
return {
data: {},
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true },
toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel'],
pageOptions: { pageSize: 10, pageCount: 4 },
orderService: new OrderService()
};
},
mounted() {
let state = { skip: 0, take: 10 };
this.dataStateChange(state);
},
methods:{
dataStateChange: function (state) {
this.orderService.execute(state).then(( gridData ) => this.data = gridData );
},
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());
}
}
},
provide: {
grid: [Sort, Group, Page, Edit, Toolbar]
}
});
script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/material.css";
style>
I have 4 questions :
1/ Is there a way to get the OderService class please, to check the addRecord and subscribe code ??
2/ I don't understand this line :
import { OrderService } from "./order-service"; order-service does not avec any extension /type of file, as js or php ?
=> Should'nt it be "
import { OrderService } from "./order-service.js";" ?
3/ I don't really get how the "state" property works :
Where are the state.action and state.requestType declared / inizialized ? Do you have a documentation that explains it ?
The Grid uses DataManager
which supports both RESTful JSON data services binding and local JavaScript object array binding. The dataSource
property can be assigned either with the instance of DataManager
or JavaScript object array collection. It supports two kinds of data binding methods:
To learn about Grid data binding quickly, you can check on this video:
To bind local data to the grid, you can assign a JavaScript object array to the dataSource
property. The local data source can also be provided as an instance of the DataManager
.
By default,
DataManager
usesJsonAdaptor
for local data-binding.
To bind remote data to grid component, assign service data as an instance of DataManager
to the dataSource
property. To interact with remote data source, provide the endpoint url
.
By default,
DataManager
usesODataAdaptor
for remote data-binding.
OData is a standardized protocol for creating and consuming data. You can retrieve data from OData service using DataManager. You can refer to the following code example of remote data binding using OData service.
The ODataV4 is an improved version of OData protocols, and the DataManager
can also retrieve and consume OData v4 services. For more details on OData v4 services, refer to the odata documentation. To bind OData v4 service, use the ODataV4Adaptor
.
You can use WebApiAdaptor
to bind grid with Web API created using OData endpoint.
<template>
<div id="app">
<ejs-grid :dataSource="data">
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90>e-column>
<e-column field='CustomerID' headerText='Customer ID' width=120>e-column>
<e-column field='Freight' headerText='Freight' textAlign='Right' format='C2' width=90>e-column>
<e-column field='OrderDate' headerText='Order Date' textAlign='Right' format='yMd' type='date' width=120>e-column>
e-columns>
ejs-grid>
div>
template>
<script>
import Vue from "vue";
import { GridPlugin } from "@syncfusion/ej2-vue-grids";
import { DataManager, WebApiAdaptor } from "@syncfusion/ej2-data";
Vue.use(GridPlugin);
export default Vue.extend({
data() {
return {
data: new DataManager({
url: 'api/Orders',
adaptor: new WebApiAdaptor(),
crossDomain: true
})
};
}
});
script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/material.css";
style>
The response object should contain properties Items
and Count
whose values are a collection of entities and the total count of the entities respectively.
The sample response object should look like below.
{
Items: [{..}, {..}, {..}, ...],
Count: 830
}
You may need to perform all Grid Actions in client-side except the CRUD operations, that should be interacted with server-side to persist data. It can be achieved in Grid by using RemoteSaveAdaptor
.
Datasource must be set to json
property and set RemoteSaveAdaptor
to the adaptor
property. CRUD operations can be mapped to server-side using updateUrl
, insertUrl
, removeUrl
, batchUrl
, crudUrl
properties.
You can use the following code example to use RemoteSaveAdaptor
in Grid.
<template>
<div id="app">
<ejs-grid :dataSource="dataSource" :editSettings='editSettings' :toolbar='toolbar'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' :isPrimaryKey='true' textAlign='Right' width=90>e-column>
<e-column field='CustomerID' headerText='Customer ID' width=120>e-column>
<e-column field='Freight' headerText='Freight' textAlign='Right' format='C2' width=90>e-column>
<e-column field='OrderDate' headerText='Order Date' textAlign='Right' format='yMd' type='date' width=120>e-column>
e-columns>
ejs-grid>
div>
template>
<script>
import Vue from "vue";
import { GridPlugin, Toolbar, Edit } from "@syncfusion/ej2-vue-grids";
import { DataManager, RemoteSaveAdaptor } from "@syncfusion/ej2-data";
import { data } from './datasource.js';
Vue.use(GridPlugin);
export default Vue.extend({
data() {
return {
dataSource: new DataManager({
json: data,
adaptor: new RemoteSaveAdaptor,
insertUrl: '/Home/Insert',
updateUrl: '/Home/Update',
removeUrl: '/Home/Delete'
}),
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true },
toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel']
};
},
provide: {
grid: [Edit, Toolbar]
}
});
script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/material.css";
style>
The following code example describes the CRUD operations handled at server-side.
public ActionResult Update(OrdersDetails value)
{
...
return Json(value);
}
public ActionResult Insert(OrdersDetails value)
{
...
return Json(value);
}
public ActionResult Delete(int key)
{
...
return Json(data);
}
You can create your own adaptor by extending the built-in adaptors. For the sake of demonstrating custom adaptor approach, we are going to see how to add a serial number for the records by overriding the built-in response processing using the processResponse
method of the ODataAdaptor
.
On remote data binding, all grid actions such as paging, sorting, editing, grouping, filtering, etc, will be processed on server-side. To avoid post back for every action, set the grid to load all data on initialization and make the actions process in client-side. To enable this behavior, use the offline
property of DataManager
.
To add a custom parameter to the data request, use the addParams
method of Query
class. Assign the Query
object with additional parameters to the grid query
property.
The parameters added using the
query
property will be sent along with the data request for every grid action.
During server interaction from the grid, some server-side exceptions may occur, and you can acquire those error messages or exception details in client-side using the actionFailure
event.
The argument passed to the actionFailure
Grid event contains the error details returned from the server.
<template>
<div id="app">
<ejs-grid :dataSource="data" :actionFailure='actionFailure'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90>e-column>
<e-column field='CustomerID' headerText='Customer ID' width=120>e-column>
<e-column field='Freight' headerText='Freight' textAlign='Right' format='C2' width=90>e-column>
<e-column field='OrderDate' headerText='Order Date' textAlign='Right' format='yMd' type='date' width=120>e-column>
e-columns>
ejs-grid>
div>
template>
<script>
import Vue from "vue";
import { GridPlugin } from "@syncfusion/ej2-vue-grids";
import { DataManager, ODataAdaptor } from "@syncfusion/ej2-data";
Vue.use(GridPlugin);
export default Vue.extend({
data() {
return {
data: new DataManager({
url: 'http://some.com/invalidUrl',
adaptor: new ODataAdaptor()
})
};
},
methods: {
actionFailure: function() {
alert('Server exception: 404 Not found');
}
}
});
script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/material.css";
style>
The
actionFailure
event will be triggered not only for the server errors, but also when there is an exception while processing the grid actions.
It is possible to handle data processing externally and bind the result to the grid. This help you to provide your own custom data logic. Grid expects an object as the result of the custom logic and the emitted value should be an object with properties result
and count
.
In this context, we are going to use
Ajax
from our@syncfusion/ej2-base
library for handling remote interaction, you can choose any HTTP client as per your choice.
<template>
<div id="app">
<ejs-grid :dataSource='data' :allowPaging='true' :pageSettings='pageOptions' :allowSorting='true' :allowGrouping='true' :dataStateChange='dataStateChange'>
<e-columns>
<e-column field= "OrderID" headerText="Order ID" width="130" textAlign='Right' >e-column>
<e-column field= "CustomerID" headerText="Customer Name" width="150">e-column>
<e-column field= "ShipName" headerText="Ship Name" width="200">e-column>
<e-column field= "ShipCity" headerText="Ship City" width="150">e-column>
e-columns>
ejs-grid>
div>
template>
<script>
import Vue from "vue";
import { GridPlugin, DataStateChangeEventArgs, Sorts, Sort, Group, Page, DataResult } from "@syncfusion/ej2-vue-grids";
import { Ajax } from '@syncfusion/ej2-base';
Vue.use(GridPlugin);
export default Vue.extend({
data() {
return {
data: {},
pageOptions: { pageSize: 10, pageCount: 4 },
orderService: new OrderService()
};
},
mounted() {
let state = { skip: 0, take: 10 };
this.dataStateChange(state);
},
methods:{
dataStateChange: function (state) {
this.orderService.execute(state).then(( gridData ) => this.data = gridData );
}
},
provide: {
grid: [Sort, Group, Page]
}
});
export class OrderService {
public ajax: Ajax = new Ajax({
type: 'GET', mode: true,
onFailure: (e: Error) => { return false; }
});
private BASE_URL: string = 'https://js.syncfusion.com/demos/ejServices/Wcf/Northwind.svc/Orders';
public execute(state: DataStateChangeEventArgs): Promise<DataResult> {
return this.getData(state);
}
private getData(state: DataStateChangeEventArgs): Promise<DataResult> {
const pageQuery = `$skip=${state.skip}&$top=${state.take}`;
let sortQuery: string = '';
if ((state.sorted || []).length) {
sortQuery = `&$orderby=` + (<any> state).sorted.map((obj: Sorts) => {
return obj.direction === 'descending' ? `${obj.name} desc` : obj.name;
}).reverse().join(',');
}
this.ajax.url = `${this.BASE_URL}?${pageQuery}${sortQuery}&$inlinecount=allpages&$format=json`;
return this.ajax.send().then((response: any) => {
let data: any = JSON.parse(response);
return <DataResult> { result: data['d']['results'], count: parseInt(data['d']['__count'], 10) };
});
}
}
script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/material.css";
style>
For grid actions such as paging
, grouping
, sorting
etc, the dataStateChange
event will be invoked. You have to query and resolve data using AJAX
in this event based on the state arguments.
<template>
<div id="app">
<ejs-grid :dataSource='data' :allowPaging='true' :pageSettings='pageOptions' :allowSorting='true' :allowGrouping='true' :dataStateChange='dataStateChange'>
<e-columns>
<e-column field= "OrderID" headerText="Order ID" width="130" textAlign='Right' >e-column>
<e-column field= "CustomerID" headerText="Customer Name" width="150">e-column>
<e-column field= "ShipName" headerText="Ship Name" width="200">e-column>
<e-column field= "ShipCity" headerText="Ship City" width="150">e-column>
e-columns>
ejs-grid>
div>
template>
<script>
import Vue from "vue";
import { GridPlugin, DataStateChangeEventArgs, Sorts, Sort, Group, Page, DataResult } from "@syncfusion/ej2-vue-grids";
import { Ajax } from '@syncfusion/ej2-base';
Vue.use(GridPlugin);
export default Vue.extend({
data() {
return {
data: {},
pageOptions: { pageSize: 10, pageCount: 4 },
orderService: new OrderService()
};
},
mounted() {
let state = { skip: 0, take: 10 };
this.dataStateChange(state);
},
methods:{
dataStateChange: function (state) {
this.orderService.execute(state).then(( gridData ) => this.data = gridData );
}
},
provide: {
grid: [Sort, Group, Page]
}
});
export class OrderService {
public ajax: Ajax = new Ajax({
type: 'GET', mode: true,
onFailure: (e: Error) => { return false; }
});
private BASE_URL: string = 'https://js.syncfusion.com/demos/ejServices/Wcf/Northwind.svc/Orders';
public execute(state: DataStateChangeEventArgs): Promise<DataResult> {
return this.getData(state);
}
private getData(state: DataStateChangeEventArgs): Promise<DataResult> {
const pageQuery = `$skip=${state.skip}&$top=${state.take}`;
let sortQuery: string = '';
if ((state.sorted || []).length) {
sortQuery = `&$orderby=` + (state).sorted.map((obj: Sorts) => {
return obj.direction === 'descending' ? `${obj.name} desc` : obj.name;
}).reverse().join(',');
}
this.ajax.url = `${this.BASE_URL}?${pageQuery}${sortQuery}&$inlinecount=allpages&$format=json`;
return this.ajax.send().then((response: any) => {
let data: any = JSON.parse(response);
return { result: data['d']['results'], count: parseInt(data['d']['__count'], 10) };
});
}
}
script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/material.css";
style>
The dataSourceChanged
event will be triggered for updating the grid data. You can perform the save operation based on the event arguments and you need to call the endEdit
method to indicate the completion of save operation.
<template>
<div id="app">
<ejs-grid :dataSource='data' :allowPaging='true' :pageSettings='pageOptions' :allowSorting='true' :allowGrouping='true' :dataStateChange='dataStateChange' :editSettings='editSettings' :toolbar='toolbar'>
<e-columns>
<e-column field= "OrderID" headerText="Order ID" :isPrimaryKey='true' width="130" textAlign='Right' >e-column>
<e-column field= "CustomerID" headerText="Customer Name" width="150">e-column>
<e-column field= "ShipName" headerText="Ship Name" width="200">e-column>
<e-column field= "ShipCity" headerText="Ship City" width="150">e-column>
e-columns>
ejs-grid>
div>
template>
<script>
import Vue from "vue";
import { GridPlugin, DataStateChangeEventArgs, Sorts, Sort, Group, Page, DataResult, Toolbar, Edit } from "@syncfusion/ej2-vue-grids";
import { OrderService } from "./order-service";
Vue.use(GridPlugin);
export default Vue.extend({
data() {
return {
data: {},
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true },
toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel'],
pageOptions: { pageSize: 10, pageCount: 4 },
orderService: new OrderService()
};
},
mounted() {
let state = { skip: 0, take: 10 };
this.dataStateChange(state);
},
methods:{
dataStateChange: function (state) {
this.orderService.execute(state).then(( gridData ) => this.data = gridData );
},
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/ And in this example :
<template>
<div id="app">
<ejs-grid :dataSource='data' :allowPaging='true' :pageSettings='pageOptions' :allowSorting='true' :allowGrouping='true' :dataStateChange='dataStateChange'>
<e-columns>
<e-column field= "OrderID" headerText="Order ID" width="130" textAlign='Right' ></e-column>
<e-column field= "CustomerID" headerText="Customer Name" width="150"></e-column>
<e-column field= "ShipName" headerText="Ship Name" width="200"></e-column>
<e-column field= "ShipCity" headerText="Ship City" width="150"></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
import Vue from "vue";
import { GridPlugin, DataStateChangeEventArgs, Sorts, Sort, Group, Page, DataResult } from "@syncfusion/ej2-vue-grids";
import { Ajax } from '@syncfusion/ej2-base';
Vue.use(GridPlugin);
export default Vue.extend({
data() {
return {
data: {},
pageOptions: { pageSize: 10, pageCount: 4 },
orderService: new OrderService()
};
},
mounted() {
let state = { skip: 0, take: 10 };
this.dataStateChange(state);
},
methods:{
dataStateChange: function (state) {
this.orderService.execute(state).then(( gridData ) => this.data = gridData );
}
},
provide: {
grid: [Sort, Group, Page]
}
});
How does the "then" from "this.orderService.execute(state).then(( gridData ) => this.data = gridData );
" work ?
Why is it different from the "this.orderService.addRecord(state).subscribe(() => state.endEdit());
from the previous example ? In fact, I don't understand what I have to use to add new datas is my grid.
In a creation case, do I have to use this.orderService.execute(state).then(( gridData ) => this.data = gridData or this.orderService.addRecord(state).subscribe(() => state.endEdit() ?
Best regards :)
And please where do I declare / import the dataSourceChanged ?
I can't see it :
<ejs-grid :dataSource='data' :allowPaging='true' :pageSettings='pageOptions' :allowSorting='true' :allowGrouping='true' :dataStateChange='dataStateChange'>
or here :
import { GridPlugin, DataStateChangeEventArgs, Sorts, Sort, Group, Page, DataResult,
or in the mounted part :
mounted() { let state = { skip: 0, take: 10 }; this.dataStateChange(state); },
<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> |