I have an editable grid in the app.component where one of the columns is a CellRendererFramework:
createColumnDefs() {
return [
{ headerName: 'First Name', field: 'firstName', editable: true },
{ headerName: 'Last Name', field: 'lastName', editable: true },
{ headerName: 'Email', field: 'email', editable: true },
{ headerName: 'Admins', field: 'admins', cellRendererFramework: ComboBoxComponent },
];
}
The component is defined as follows:
import { Component, OnInit } from '@angular/core';
import { User, DataService } from './data.service';
import { ICellRendererAngularComp } from 'ag-grid-angular';
@Component({
selector: 'app-combo-box',
templateUrl: './combo-box.component.html',
styleUrls: ['./combo-box.component.css']
})
export class ComboBoxComponent implements OnInit, ICellRendererAngularComp {
users: User[] = [];
admins: any;
constructor(private dataservice: DataService) {}
ngOnInit() {
this.users = this.dataservice.getAdminUsers();
}
refresh(params: any): boolean {
return false;
}
public params: any;
agInit(params: any): void {
this.params = params;
this.admins = this.params.value;
}
public getFollows(){
return this.admins;
}
onChange(evt){
this.admins = evt.value;
}
}
The template 'combo-box.component.html' is a material select with multi select option enabled.
<mat-form-field> <mat-select multiple [(value)]="admins" (selectionChange)="onChange($event)">
<mat-option *ngFor="let user of users | async" [value]="user.firstName">{{user.firstName}}</mat-option> </mat-select> </mat-form-field>
I should be able to change the data in the multi select and then on the clic of an external button, I should save the grid data. The problem I am facing is whenever I change the multi select option and then try to save, it always shows the multiselect's value that was bound initially.
So basically, any change in the ComboBoxComponent is not changing the rowData. Hence I am not able to save back the grid data after modification.
What am I missing?
I am using Ag-grid version: 17.1.0 Angular: 6.0.3