在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 –