save data in Vuex Store at realtime
|
actionBegin:
actionBegin: function(args) {
if (args.requestType === "save") {
console.log(args.data); // edited data
// PLease store this data in Vuex store
}
}
BeforeBatchSave:
beforeBatchSave: function(args) {
console.log("Edited records :" + args.batchChanges.changedRecords); // edited records
console.log("Deleted records :" + args.batchChanges.deletedRecords); // deleted records
console.log("Added records :" + args.batchChanges.addedRecords); // added records
// you can collected edited record details like as above code
} |
know i have İn products table a column calls "categories_id" as foreignkey and can see the data in Store. Know i want to know how can i define a second datasource for the foreign column to show the data at the same time with my products
|
<template>
<div class="col-lg-12 control-section">
<div>
<ejs-grid :dataSource="data" :allowPaging='true'
:editSettings='editOptions' :toolbar='toolbarItems' >
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='120' :isPrimaryKey='true'></e-column>
<e-column field='CustomerID' headerText='Customer Name' width='150' :validationRules='orderidrules'
foreignKeyValue='ContactName' foreignKeyField='CustomerID' :dataSource='customerData'></e-column>
</e-columns>
</ejs-grid>
</div>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import { GridPlugin, ForeignKey, Toolbar, Page } from "@syncfusion/ej2-vue-grids";
import { orderDetails, customerData } from "./data-source";
Vue.use(GridPlugin);
export default Vue.extend({
data: () => {
return {
data: orderDetails.slice(0),
toolbarItems : ['Add', 'Edit', 'Delete', 'Update', 'Cancel'],
customerData : customerData,
};
},
provide: {
grid: [ForeignKey, Page, Toolbar]
}
});
</script> |
Attachment: productssample_5f621785.zip
Another problem i have is that actually the columnnames from my datagrid comes from the database column. İ don't want this. İ want to set the Columnnames as i want.
How can i solve this.
|
<template>
<div id="app">
<input @change="change" type="checkbox">
<ejs-grid id="Grid" ref="grid" :height="400" :dataSource="data" :columns="columns"></ejs-grid>
</div>
</template>
<script>
import Vue from "vue";
import { GridPlugin } from "@syncfusion/ej2-vue-grids";
import { data, employee } from "./datasource";
Vue.use(GridPlugin);
export default {
data() {
return {
data: data,
columns: [
{
field: "OrderID",
headerText: "Order ID",
width: 120,
textAlign: "Right"
},
{ field: "CustomerID", headerText: "Customer Name", width: 150 }
],
cTemplate: function() {
return {
template: Vue.component("columnTemplate", {
template: `<span>{{modify(data.index)}}</span>`,
data: function(e) {
return {
data: {}
};
},
methods: {
modify: function(e) {
return parseInt(e, 0) + 1;
}
}
})
};
}
};
},
provide: {},
methods: {
change: function(e) {
if (e.target.checked) {
this.data = employee;
this.columns = [
{
field: "EmployeeID",
headerText: "Employee ID",
textAlign: "Right",
width: 125
},
{ field: "FirstName", headerText: "Name", width: 120 }
];
} else {
this.data = data;
this.columns = [
{
field: "OrderID",
headerText: "Order ID",
width: 120,
textAlign: "Right"
},
{ field: "CustomerID", headerText: "Customer Name", width: 150 }
];
}
}
}
};
</script>
|
i found your documentation (https://ej2.syncfusion.com/vue/documentation/grid/how-to/render-other-components-in-column/) but here he define the template into the column tag like:
<e-column headerText='Order Status' :template="dropdownTemplate" width=200></e-column>How can i add a component as i want.
|
[App.Vue]
<template>
<div id="app">
<input @change="change" type="checkbox">
<ejs-grid
id="Grid"
ref="grid"
:height="400"
:queryCellInfo="onQueryCellInfo"
:dataSource="data"
:columns="columns"
></ejs-grid>
</div>
</template>
<script>
import Vue from "vue";
import { GridPlugin } from "@syncfusion/ej2-vue-grids";
import {
DropDownListPlugin,
DropDownList
} from "@syncfusion/ej2-vue-dropdowns";
import { data, employee } from "./datasource";
Vue.use(GridPlugin);
Vue.use(DropDownListPlugin, DropDownList);
export default {
data() {
return {
data: data,
columns: [
{
headerText: "Order Details",
template:
'<div><select class="e-control e-dropdownlist"><option value="1" selected="selected">Order Placed</option><option value="2">Processing</option><option value="3">Delivered</option></select></div>'
},
],
};
},
provide: {},
methods: {
onQueryCellInfo: function(args) {
var ele = args.cell.querySelector("select");
if (ele) {
var dropdown = new DropDownList({ popupHeight: 150, popupWidth: 150 });
dropdown.appendTo(ele);
}
},
}
}
}
};
</script>
|
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link. It is pending for review and once it has been reviewed, this can be viewed.
https://www.syncfusion.com/feedback/8761/complex-data-is-not-rendering-properly-while-using-autogenerate-columns
Hi Seeni,
thank you for your support.
İ have a table in my project. This datagrid contains data from three more tables. İ have a Syncfusion Actionbegin method and i want to execute delete, add and save actions. To execute an add action my datagrid contains a dialog template. When I trigger a new entry I get an error message in console;
name: "BadRequest", message: "notNull Violation: products.id cannot be null
This error may be due to the fact that in our ORM model and in our database table the id fields are not allowed to be null. Also my dialog template from datagrid does not contain an idfield to fill when creating or editing a entry.
İn my product table i have named primarykeyfield as id for test purposes (see attachments). The remaining tables were named as table name + _id can this lead to this error message? How can i solve this?
Attachment: products_a27e9969.zip
|
// Join the three tables into single
var query = from a in _context.Orders join b in customer on a.CustomerID equals b.CustomerID select new { a.CustomerID, a.EmployeeID,a.OrderDate,a.OrderID,a.ShipCity,b.CustomerName};
IEnumerable MergeTable = from x in query join y in employee on x.CustomerName equals y.CustomerName select new { x.OrderID, x.CustomerName, x.CustomerID, x.EmployeeID, x.OrderDate, x.ShipCity, y.Address };
|
- 13 Replies
- 4 Participants
-
NA Nurhan Aydogdu
- Jul 10, 2019 07:14 AM UTC
- Nov 25, 2019 06:47 AM UTC