当我在另一个单元格中选择一个值时如何更改单元格的值

how to change the value of a cell when I choose a value in another

我目前在 angular 6 下的应用程序中使用 ag-grid,我的问题是: 我有一行 3 列,| A | B | C |

A 是一个有一些名字的 select 当我 select 行 A 中的一个值时,我希望 BC(同一行)根据 A 的日期更改它们的值.

A = { id:number , aStart:Date, aEnd:Date }

我试过使用 startEditingCell 和其他方法,但没有人奏效。

这样做的正确方法是什么?

export interface Delivery {
    id: number;
    deliveryCode: string;
    startPeriodDate: Date;
    endPeriodDate: Date;
    description: string;
    inactive: boolean;
}

export class lineColumn {
    deliveryid: number
    startDate: Date
    endDate: Date
}
const columns = {
                headerName: 'Delivery',
                colId: 'delivery',
                field: 'id',
                editable: this.isGridEditableOnCondition,
                cellEditor: 'agRichSelectCellEditor',
                cellRenderer: this.deliveryFormatter.bind(this),
                cellEditorParams: (params) => {
                    return {
                        values: this.deliveries.map((delivery) => delivery.id),
                        formatValue: this.deliveryFormatter.bind(this),
                        displayPropertyName: 'deliveryCode',
                        valuePropertyName: 'deliveryCode',
                        displayFormat: 'deliveryCode',
                    };
                },
                onCellValueChanged: (params) => {
                    // when this value changes, the other 2 columns must change with the values of dates that delivery has (but can be still editables)
                    params.api.refreshCells();
                },
            },
            {
                headerName: 'Shipping Start Date',
                colId: 'shippingStartDate',
                field: startDate,
                editable: this.isGridEditable,
                valueFormatter: this.uiService.dateFormatter,
                cellEditor: 'atrDate',
            },
            {
                headerName: 'Shipping End Date',
                colId: 'shippingEndDate',
                field: endDate,
                editable: this.isGridEditable,
                valueFormatter: this.uiService.dateFormatter,
                cellEditor: 'atrDate',
            },

最后:

 onCellValueChanged: (params) => {

                        const api: agGrid.GridApi = params.api;
                        const delivery = this.masterdata.deliveries.find((d: Delivery) => d.deliveryId === params.newValue);
                        api.getRowNode(params.node.rowIndex).setDataValue('shippingStartDate', delivery.startPeriodDate);
                        api.getRowNode(params.node.rowIndex).setDataValue('shippingEndDate', delivery.endPeriodDate);

                        api.refreshCells();
                    }
                },