|
<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='Password'
headerText='Password ID' width='140' [validationRules]='customeridrules' [edit]="editParams" // CellEditTemplate > </e-column>
</e-columns>
</ejs-grid>
|
|
[app.component.ts]
export class AppComponent {
@ViewChild("normalgrid")
public grid: GridComponent;
public editParams: IEditCell;
public elem: HTMLElement;
public textBox: TextBox;
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.textBox.value;
},
destroy: () => { //destroy function is used to destroy the component.
this. textBox.destroy();
},
write: (args: any) => { //write function is used to create custom component or assign default value at time of editing.
this.textBox = new TextBox({ //TextBox component
placeholder: 'Enter the Password',
type: 'Password',
floatLabelType: 'Auto'
});
this.textBox.appendTo(this.elem);
}
};
} |