我在 Angular (5) 应用程序中使用 KendoUI-Grid。
html:
<kendo-grid [data]="GRIDData"
(add)="addHandler($event)">
<ng-template kendoGridToolbarTemplate>
<button kendoGridAddCommand type="button">Add new</button>
</ng-template>
成分:
public addHandler({sender}) {
this.formGroup = createFormGroup({
'Id': 'NEW',
'Name': 'New entry'
});
sender.addRow(this.formGroup);
}
是否可以从网格外部触发 addCommand (或任何其他命令)?也许是这样的:
html:
<button (click)="gridAddRow()"> Add New Row to Grid</button>
成分:
gridAddRow() {
**//calling addHandler ({sender})**
}
THX
是的!网格是一个组件。你只需要一个对它的引用。
HTML:
<kendo-grid [data]="GRIDData"
(add)="addHandler($event)">
<ng-template kendoGridToolbarTemplate>
<button kendoGridAddCommand type="button">Add new</button>
</ng-template>
成分:
@ViewChild(GridComponent) private grid: GridComponent;
gridAddRow() {
**//calling addHandler ({sender})**
this.grid.addRow(** your form group goes here **)
}
堆栈闪电战https://stackblitz.com/edit/angular-ruohgs https://stackblitz.com/edit/angular-ruohgs
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)