KendoUI Angular Grid外部命令 [英] KendoUI Angular Grid external command

查看:82
本文介绍了KendoUI Angular Grid外部命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Angular(5)应用程序中使用KendoUI-Grid.

i'm using KendoUI-Grid in an Angular (5) app.

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

推荐答案

是的!网格是一个组成部分.您只需要引用它即可.

Yup! the grid is a component. You just need a reference to it.

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 **)
}

stackblitz https://stackblitz.com/edit/angular-ruohgs

stackblitz https://stackblitz.com/edit/angular-ruohgs

这篇关于KendoUI Angular Grid外部命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆