我正在尝试将数据项从剑道网格传递到Angular 6上的组件。设置如下。
<kendo-grid
[data]="view | async"
[height]="533"
(dataStateChange)="onStateChange($event)"
(edit)="editHandler($event)" (remove)="removeHandler($event)"
(add)="addHandler($event)"
>
<ng-template kendoGridToolbarTemplate>
<button kendoGridAddCommand>Add new</button>
</ng-template>
<kendo-grid-column field="Id" title="ID"></kendo-grid-column>
<kendo-grid-column field="Name" title="Company Name"></kendo-grid-column>
<kendo-grid-column field="BillingInfo.BillingGroup" title="Group"></kendo-grid-column>
<kendo-grid-column field="DefaultProcessingLocation" title="Default Location"></kendo-grid-column>
<kendo-grid-column field="BillingInfo.BillingCode" title="Code"></kendo-grid-column>
<kendo-grid-command-column title="Action" width="300">
<ng-template kendoGridCellTemplate let-dataItem>
<button kendoGridEditCommand [primary]="true">Edit</button>
<button kendoGridRemoveCommand>Delete</button>
<button (click)="getCustomerJobs(dataItem)">Jobs</button>
</ng-template>
</kendo-grid-command-column>
</kendo-grid>
<app-edit-customer [model]="editDataItem" [isNew]="isNew"
(save)="saveHandler($event)"
(cancel)="cancelHandler()">
</app-edit-customer>
当我单击编辑或删除dataItem时,我看到了dataItem。但是,当我单击“作业”时,getCustomerJobs将dataItem返回为“未定义”。
预先感谢您的帮助。
答案 0 :(得分:0)
我相信你很亲密。问题在于 kendo-grid-column 上的标记。
更改此( kendo-grid-command-column )...
<kendo-grid-command-column title="Action" width="300">
<ng-template kendoGridCellTemplate let-dataItem>
<button kendoGridEditCommand [primary]="true">Edit</button>
<button kendoGridRemoveCommand>Delete</button>
<button (click)="getCustomerJobs(dataItem)">Jobs</button>
</ng-template>
</kendo-grid-command-column>
为此( kendo-grid-column )..
<kendo-grid-column title="Action" width="300">
<ng-template kendoGridCellTemplate let-dataItem>
<button kendoGridEditCommand [primary]="true">Edit</button>
<button kendoGridRemoveCommand>Delete</button>
<button (click)="getCustomerJobs(dataItem)">Jobs</button>
</ng-template>
</kendo-grid-column>