|
import { Component, OnInit,ViewChild } from '@angular/core';
import { data } from './data';
import { CheckBoxModule, ButtonModule } from '@syncfusion/ej2-ng-buttons';
import { EditService, PageService,GridComponent } from '@syncfusion/ej2-ng-grids';
@Component({
selector: 'app-container',
template: `<ejs-grid #grid [datasource]='data' [editsettings]='editSettings' [editsettings]='editSettings' [toolbar]='toolbar' [height]='300'>
<e-columns>
<e-column headertext='Order Status' width='200'>
<ng-template #template let-data>
<div>
<ejs-checkbox [checked]=data.OrderStatus></ejs-checkbox>
</div>
</ng-template>
</e-column>
<e-column field='OrderID' headertext='Order ID' isPrimaryKey= true textalign='Right' width=90></e-column>
</e-columns>
</ejs-grid>
})
export class BatchEditComponent implements OnInit {
@ViewChild('grid')
public grid: GridComponent;
public ngOnInit(): void {
}
applyClicked(): void {
this.grid.editModule.batchSave();
alert(this.grid.getCurrentViewRecords()[0].CustomerID);
} |
|
<ejs-grid #grid [dataSource]='data' [editSettings]='editSettings'[editSettings]='editSettings' [toolbar]='toolbar' [height]='300'>
<e-columns>
<e-column headerText='Order Status'width='200'>
<ng-template #template let-data>
<div>
<ejs-checkbox [checked]=data.OrderStatus (change)='change($event)'></ejs-checkbox>
</div>
</ng-template>
</e-column>
<e-column headerText='Color' field ='color' textAlign='Center' width=80 >
<ng-template #template let-data>
<div>
<input type="color" value={{data.color}} id='colorpicker' (change)="colorchange($event)" style="border-width: 0px;height: 20px;">
</div>
</ng-template>
</e-column>
</e-columns>
</ejs-grid>
colorchange(args):void{
let rowUID: string =parentsUntil(args.target,'e-row').getAttribute('data-uid');
let currentRowObject: Object= this.grid.getRowObjectFromUID(rowUID);
let currentRowData: Object = currentRowObject.data;
currentRowData['color'] = args.target.value; //changed the colorpicker sataus
currentRowObject.changes = currentRowData;
}
change(args):void {
. . . . .
currentRowData['OrderStatus'] = args.checked; //changed the checkbox sataus
} |
|
<ejs-grid #grid [dataSource]='data' (actionBegin)='actionBegin($event)' (rowSelected)='selected($event)' [editSettings]='editSettings' [editSettings]='editSettings' [toolbar]='toolbar' [height]='300'>
<e-columns>
<e-column headerText='Order Status' width='200'>
<e-column headerText='Shape' width=150 foreignKeyField="shape" foreignKeyValue='Value'>
<ng-template #template let-data>
<ejs-dropdownlist [dataSource]='testShape' (change)='dropDownChange($event)' [value]=data.shape [fields]='shapeField'></ejs-dropdownlist>
</ng-template>
</e-column>
</e-columns>
</ejs-grid>
export class BatchEditComponent implements OnInit {
selected(args):void {
this.rowID = args.target.parentElement.getAttribute('data-uid');//Get rowUID
}
dropDownChange(args):void {
let currentRowObject: Object = this.grid.getRowObjectFromUID(this.rowID);
let currentRowData: Object = currentRowObject.data;
currentRowData['shape'] = args.itemData.shape;//Change the dropdown value
currentRowObject.changes = currentRowData;
}
|
|
selected(args):void {
this.colField=this.grid.getColumns()[args.cellIndex.cellIndex].field //get the selected cell field
}
test(args):void{
let rowUID: string =parentsUntil(args.target,'e-row').getAttribute('data-uid');
let currentRowObject: Object= this.grid.getRowObjectFromUID(rowUID);
let currentRowData: Object = currentRowObject.data;
currentRowData[this.colField] = args.target.value;
currentRowObject.changes = currentRowData;
} |
|
test(args):void{
let rowUID: string =parentsUntil(args.target,'e-row').getAttribute('data-uid');
let currentRowObject: Object= this.grid.getRowObjectFromUID(rowUID);
let info:Object =this.grid.getRowInfo(args.target);
alert(info.column.field)
let currentRowData: Object = currentRowObject.data;
currentRowData[info.column.field] = args.target.value;
currentRowObject.changes = currentRowData;
} |