【问题标题】:I want to make ag-grid cell editable on click event of checkbox我想在复选框的单击事件上使 ag-grid 单元格可编辑
【发布时间】:2019-05-26 00:41:42
【问题描述】:

如果我在定义网格时将可编辑属性设置为 true,则它已启用,但如果我在复选框的单击事件中将其设置为 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 }

【问题讨论】:

    标签: angular6 ag-grid


    【解决方案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){
        ....
    }
    

    【讨论】:

      猜你喜欢
      • 2016-07-04
      • 1970-01-01
      • 2019-10-26
      • 2020-06-14
      • 2018-07-01
      • 2017-06-17
      • 2016-07-10
      • 2021-12-29
      • 2019-01-10
      相关资源
      最近更新 更多