我想在复选框的单击事件中使ag-grid单元格可编辑

时间:2018-12-28 06:00:28

标签: angular6 ag-grid

如果我在定义网格时将editable属性设置为true,则启用它,但是如果我在复选框的click事件上将其设置为true,则其值将被更改,但我无法编辑该单元格。该怎么办? HTML部分

<ag-grid-angular #agGrid 
        [enableSorting]="true" 
        [rowSelection]="genericComponent.multipleRowSelection" 
        class="ag-theme-blue ag-grid-md-1"
        [gridOptions]="gridOptionsAlert" 
        (rowSelected)="onRowSelection($event)"
        [suppressClickEdit]="true"
        [stopEditingWhenGridLosesFocus]="true"
        [suppressRowClickSelection]="true" 
        (gridReady)="onGridReadyGroup($event)" 
        [components]="components"></ag-grid-angular>  `enter code here`

TS部分

{ headerName: 'New Value', field: 'NewValue', filter: 'agNumberColumnFilter',cellStyle:{ 'text-align': "right" }, width: 122 ,editable:false}








onRowSelection(event){   

this.colDef [8] .editable = true }

1 个答案:

答案 0 :(得分:1)

您可以使用function进行属性定义:

editable: (params)=>{
    let result = (Math.random()>0.5)? 1 : 0;// random true/false condition
    return result;
}

editable: this.checkEditable.bind(this)

checkEditable(params){
    ....
}