|
<div class="control-section">
<div class="col-lg-9">
<ejs-grid #normalgrid id="Normalgrid" [dataSource]="data" allowPaging="true" [pageSettings]="pageSettings" [editSettings]="editSettings" [toolbar]="toolbar" >
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='140' textAlign='Right' isPrimaryKey='true' [validationRules]='orderidrules'></e-column>
<e-column field='CustomerID' headerText='Customer ID' width='140' [validationRules]='customeridrules'></e-column>
<e-column field='Freight' headerText='Freight' width='140' format='C2' textAlign='Right' editType='numericedit' [validationRules]='freightrules'></e-column>
<e-column field='OrderDate' headerText='Order Date' width='120' [edit]="dpParams" [format]='formatoptions' textAlign='Right'></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width='150' editType='dropdownedit' type="string" ></e-column>
</e-columns>
</ejs-grid>
</div>
</div> |
|
[app.component.ts]
export class AppComponent {
public elem: HTMLElement;
public datePickerObj: DatePicker;
public dpParams: IEditCell; public ngOnInit(): void {
this.dpParams = { //cellEditTemplate
create: () => { //create function is used to create the element at time of initialization
this.elem = document.createElement("input");
return this.elem;
},
read: () => { //read function is used to read the value from component at time of save.
return this.datePickerObj.value;
},
destroy: () => { //destroy function is used to destroy the component.
this. datePickerObj.destroy();
},
write: args => { //write function is used to create custom component or assign default value at time of editing.
this.datePickerObj = new DatePicker({ //DatePicker Component
value: new Date(args.rowData[args.column.field]),
floatLabelType: 'Never',
created: created.bind(this),
});
function created(){
this.datePickerObj.inputElement.disabled = true //disable the input element of DatePicker Component
}
this.datePickerObj.appendTo(this.elem);
}; }
} |