在Angular 2的Kendo UI(测试版)中,如何在选择特定行时触发事件?行本身没有指令或组件;因此,如果没有行元素,则(click)=“triggeredFunction()”无法工作。在Kendo UI Grid中选择行时的触发事件(Angular 2)
这里是我的网格:
<kendo-grid [data]="gridData" [selectable]="true">
<kendo-grid-column field="ProductName">
<template kendoHeaderTemplate let-column let-columnIndex="columnIndex">
{{column.field}}({{columnIndex}})
</template>
</kendo-grid-column>
<kendo-grid-column field="ProductName">
<template kendoCellTemplate let-dataItem>
<kendo-dropdownlist [data]="listItems"></kendo-dropdownlist>
</template>
</kendo-grid-column>
</kendo-grid>
这里是我的组件:
@Component({
selector: "ultron",
styleUrls: [String("./ultron.component.less")],
templateUrl: "./ultron.component.html",
})
export class UltronComponent {
private gridData: any[] = [{
"ProductID": 1,
"ProductName": "Chai",
"UnitPrice": 18.0000,
"Discontinued": true,
}, {
"ProductID": 2,
"ProductName": "Chang",
"UnitPrice": 19.0000,
"Discontinued": false,
}
}];
private listItems: Array<string> = ["@", "$", "#", "%"];
public triggeredFunction(){ ... }
}
尝试'[可选择] = “ '行'”'http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-selectable –
@DanWilson,感谢您的快速回复。你发给我的链接是Angular 1(我需要Angular 2)。所以..我把我的函数放在你提到的位置[selectable] =“triggeredFunction()”,这会在页面上每次改变时触发,也会在你点击一行时触发,但是如何通过特定行数据到组件? –
我认为你需要指定“row”作为可选组件,并提供一个'(change)'处理程序,这将是你的'triggeredFunction()'。 http://demos.telerik.com/kendo-ui/grid/events –