Shivani S.
Shivani S.

Reputation: 13

I want to make ag-grid cell editable on click event of checkbox

If I'm setting editable property true when I'm defining the grid , its enabled but if I'm setting it true on click event of the checkbox its value is getting changed but I'm not able to edit the cell. What to do? HTML part

<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 part

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








onRowSelection(event){   

this.colDef[8].editable = true }

Upvotes: 1

Views: 2192

Answers (1)

un.spike
un.spike

Reputation: 5113

You could use function for properties definition:

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

or

editable: this.checkEditable.bind(this)

checkEditable(params){
    ....
}

Upvotes: 3

Related Questions