|
[app.component.ts]
export class AppComponent {
public data: Observable<DataStateChangeEventArgs>;
-----
prepareDataForGrid(data) {
console.log(data);
----
const columns = [
{
field: "OrderID",
headerText: "Order ID",
textAlign: "Right",
isPrimaryKey: true,
width: 120
},
{ field: "CustomerID", headerText: "Customer ID", width: 150 },
{
field: "Freight",
headerText: "Freight",
editType: "numericedit",
allowEditing: false,
edit: {params: { change: this.itemChange }},
width: 150
},
{
field: "EmployeeID",
headerText: "Employee ID",
editType: "numericedit",
allowEditing: false,
edit: { params: { change: this.itemChange } },
width: 150
},
{
field: "Qty",
headerText: "Qty",
editType: "numericedit",
edit: { params: { change: this.qtyChange } },
valueAccessor: this.valueAccessor,
width: 150
}
];
---
return { dataSource: itemValue, cols: columns, aggregates: aggregates };
}
actionBegin(args) {
if (args.requestType == "beginEdit") {
args.rowData.Qty = parseFloat(args.rowData["Freight"]) + parseFloat(args.rowData.EmployeeID);
}
}
qtyChange = args => {
var gridId = this.gridPoc.element.id;
var qtyValue = args.value;
// get the shared value from totalQty
var sharedValue = qtyValue / 2;
// bind the shared value to other columns
// get the freight column’s numerictextbox control using its id (grid id + column name)
(document.getElementById(gridId + "Freight") as any).ej2_instances[0].value = sharedValue;
// get the employeeID column’s numerictextbox control using its id (grid id + column name)
(document.getElementById(gridId + "EmployeeID") as any).ej2_instances[0].value = sharedValue;
console.log(this);
};
|
|
actionBegin(args) {
if (args.requestType == "beginEdit") {
// disable the editing on particular column
this.gridPoc.getColumnByField("Freight").allowEditing = false;
this.gridPoc.getColumnByField("EmployeeID").allowEditing = false;
}
}
actionComplete(args) {
if (args.requestType === "save" && args.action === "edit") {
// enable the editing on particular column
this.gridPoc.getColumnByField("Freight").allowEditing = true;
this.gridPoc.getColumnByField("EmployeeID").allowEditing = true;
}
} |