Skip to content Skip to sidebar Skip to footer

How To Show Dynamic Values In Ag-grid Cell Editor Select

I want to show dynamic drop down options for each row of ag-grid. Suppose for each row, department might be different and based on that I plan to filter list of subjects (available

Solution 1:

If I understand correctly, you want to be able to have different values in the cellEditor based on which department is selected. If that is correct, then you will likely need to do something more complicated dealing with cellEditors. Here is a plnkr that I made that checks if the name starts with a J, if so then it allows a third option.

Please refer to the plnkr for full example, as well as the docs to make sure that you get everything imported/exported in the right places. Here is what is the key importance for you beyond what is on the docs:

agInit(params: any): void {
    if (params.node.data.financingCurrency == 'Your Super Department') {
        subjects = [...super options...]
    } else {
        subjects = [...different options...]
    }
}

agInit gets called any time editing is started. params has a complicated object, (I suggest console.log()ing it just to see everything that is available to you) but basically the node is referring to the row that the cell is on, and the data is the data for that row, and judging by your colDefs you can get the value of the Department from financingCurrency.

Solution 2:

try something similar :

  {
    headerName: ' MEDICINE NAME ', 
    field: 'medicine',
    cellEditor: 'autoComplete',
    cellEditorParams:params => {
         return  {
          'propertyRendered' : 'name',
          'rowData':  this.medicineList, 
          'columnDefs' : [{headerName: 'Medicine', field:'name'}]
      } 
    } 
  },

Post a Comment for "How To Show Dynamic Values In Ag-grid Cell Editor Select"