You can do this pretty easily (took me 15 minutes).
In your onCellClicked($event)
method set a module level variable for which column was clicked.
E.g:
onCellClicked($event) {
this.fullRowEditOnlyPopup = $event.colDef.field;
if (this.editingRowIndex !== $event.rowIndex) {
$event.api.startEditingCell({
rowIndex: $event.rowIndex,
colKey: $event.column.colId
});
this.editingRowIndex = $event.rowIndex;
}
}
I have a column with a button that pops up a ICellEditorAngularComp 'cdTargetLabourDetailRenderer'
that should be the only editable item on the row when called:
this.columnDefs.push({
headerName: '',
field: 'popupEditColumn',
cellStyle: { 'text-align': 'left' },
cellEditor: 'cdTargetLabourDetailRenderer',
cellRendererParams: { buttonType: 'settings' },
cellRendererFramework: MatButtonComponent,
cellEditorParams: (params) => {
return {
resource: this.getTargetResource(params)
};
},
onCellValueChanged: (params: any) => {
if (params.node && params.node.data && params.node.data.resource) {
params.data.resource = params.node.data.resource;
params.data.description = params.node.data.resource.description;
this.gridApi.updateRowData(params.node.data);
}
this.gridApi.refreshCells();
},
editable: (params) => {
return (this.fullRowEditOnlyPopup === 'popupEditColumn');
},
});
I have 12 columns which I want to edit in full row mode, and return if they are editable depending on if the popup edit column was clicked, or a different column (including any of the 12 month columns):
this.months.forEach((month: any) => {
this.columnDefs.push({
headerName: this.datePipe.transform(month, 'MMM yy'),
field: this.datePipe.transform(month, 'MMMyy'),
type: 'numericColumn',
cellStyle: {
'text-align': 'right',
},
valueFormatter: this.labourFormatter,
editable: (params) => {
let editable = false;
if (this.fullRowEditOnlyPopup === 'popupEditColumn') { return false; }
// Perform other logic if needed for month columns
if (!doingStuffAndThings) {
editable = false;
} else {
editable = true;
}
return editable;
},
});
});
If I click on the 'popupEditorColumn'
only the ICellEditorAngularComp
displays. If I click on any other row, the full row edit of month-columns display as editable.
However, there is an annoying need to double click the cell to get into edit mode where the initial time it only requires a single click.