[英]A function is not getting invoked on ag-grid row link
Code: 码:
columndefs: [
{headerName:'PTP Users', field: 'userId', width:250, cellClass:'ag-cell-text-align-center', cellRenderer : nameLink},
{headerName:'Current Team ID', field: 'teamId', width:250, cellClass:'ag-cell-text-align-center', cellRenderer : currentTeamIdRenderer}
]
function nameLink(params) {
let result = '<span style="text-decoration:underline;color:blue;cursor:pointer" onClick="{alert('logged')}">'+params.data.userId+'</span>';
return result;
}
_showModal() {
console.log('inside showmodal');
this.setState({showModal: true});
}
If I change the onClick alert to this._showModal the "showModal" function is not getting invoked. 如果将onClick警报更改为this._showModal,则不会调用“ showModal”功能。
There may be a better (or faster way) but (in Angular 2) I would add the click event to the grid html for the row 可能有更好(或更快速)的方法,但是(在Angular 2中)我会将click事件添加到该行的表格html中
<ag-grid-ng2 id="leftgrid" #agGrid style="height: 90%; width:98%" class="ag-fresh"
[gridOptions]="gridOptions"
[columnDefs]="columnDefs"
[showToolPanel]="showToolPanel"
[rowData]="displayedFleet"
enableColResize
enableSorting
enableRangeSelection:false
enableFilter
groupUseEntireRow
externalRowSelection:true
suppressRowClickSelection:false
toolPanelSuppressGroups:true
toolPanelSuppressValues
debug
rowHeight="22"
(cellClicked)="alert2($event)"
rowSelection='single'>
Note cellClicked event 注意cellClicked事件
then in the code behind track if its the correct column dependant on header (or field) properties (if the column is important). 然后在轨道后面的代码中,其正确列是否取决于标题(或字段)属性(如果该列很重要)。
alert2(ev: any){
if(ev.colDef.headerName == "TEST"){
alert('call me');
}
}
Even if not using Angular 2 the grid will still have its html block and standard event handling that you should be able to adjust to your language of choice by looking at the event notation of the various ag-grid examples.. 即使不使用Angular 2,网格仍将具有其html块和标准事件处理,您应该能够通过查看各种ag-grid示例的事件表示法来适应所选择的语言。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.