Currently integrating agGrid into my Angular8 project. I have a specific column that needs to display an exact mapped value in a dropdown whenever I want to edit it. To achieve this, I am utilizing agSelectCellEditor. Here's a snippet of the code I'm working with:
HTML
<ag-grid-angular class="ag-theme-balham" [gridOptions]="categoryGridOptions"
[rowData]="categoryRowData" [columnDefs]="categoryColDef"
(gridReady)="onGridReady($event)">
</ag-grid-angular>
TS File
export class CategoryComponent{
categoryRowData: any[];
objCategoryMappings = [{
0: "No",
1: "Yes",
}];
categoryColDef = [
{
headerName: 'Category Name', field: 'CategoryName',
cellEditor: 'agLargeTextCellEditor',
cellEditorParams: {
maxLength: '50',
cols: '20',
rows: '1'
}
},
{
headerName: 'Is Subcategory', field: 'IsSubcategory',
cellEditor: 'agSelectCellEditor',
cellEditorParams: {
values: this.extractValues(this.objCategoryMappings),
},
cellRenderer: (params) => {
return this.mapCategory(params);
},
refData: this.objCategoryMappings,
}];
extractValues(mappings) {
return Object.keys(mappings);
}
mapCategory(objRowData : any) : string
{
if (objRowData.data.IsSubcategory == 1)
return "Yes";
else if (objRowData.data.IsSubcategory == 0)
return "No";
}
}
Upon clicking on a cell, a dropdown appears as displayed in the snapshot linked below:- https://i.sstatic.net/8UcAj.png
Could you please provide guidance on what I might be overlooking in this setup?