In Angular ag-grid, how to disable some values from selection in a dropdown

Viewed 166

I am able to pass values to a dropdown as an array, however I would like for some of the values to be non selectable to the user(disabled state). The reason being, I want to be able to toggle the disabled state of these values based on the users permissions.

By column definition is as below :-

this.columnDefs.push({
          headerName: this.FIELD_NAME.toUpperCase(),
          field: this.FIELD_NAME,
          cellStyle: getBackgroundColor,
          editable: true,
          cellClass: cellClass,
          headerTooltip: this.DESCRIPTION,
          cellEditor: 'agSelectCellEditor',
          cellEditorParams: {
            values: this.approvalStatus
          }
        })

and the array is as follows :-

approvalStatus: any[] = [{name: 'Not Started',disable: false},{name: 'Work In Progress',disable: false},
     {name: 'On Hold',disable: false},{name: 'Pending',disable: true},
   {name: 'Completed',disable: true}];

I would like the user to be able to see all 5 options in the dropdown but not be able to select 'Pending' & 'Completed'.

Am I doing anything wrong or do I need to use a different cellEditor in this case?

0 Answers
Related