I am using AngularJS with the JS version of ag-grid-community. When I go to edit the field, the DDL is not defaulting to the current item? To get a key/value pair to work I had to alter ag-grid-community.js to not throw an error on dataTypeMatcher using skipCheckType.
cellEditorParams.values is an array of { key: ..., name: ...} pairs.
{
headerName: 'Frequency', field: "Frequency",
cellEditor: 'agSelectCellEditor',
singleClickEdit: true,
cellEditorParams: {
values: $scope.gridFrequencies,
},
valueFormatter: (params) => {
console.log('valueFormatter', params);
return params.value?.name ? params.value.name: $scope.gridFrequencies.find(o => o.key == params.value)?.name;
},
valueSetter: params => {
if (params.newValue) {
params.data.Frequency = params.newValue.key;
return true; // indicates that the value was successfully set
}
return false; // indicates that the value was not set
},
skipCheckType: true,
tooltipValueGetter: params => {
return params.data.Frequency;
}
}
ag-grid-community.js change