【发布时间】:2020-02-17 18:01:20
【问题描述】:
我目前在 Angular 6 下的应用程序中使用 ag-grid,我的问题是:
我有一排 3 列,| A | B | C |
A 是一个带有一些名称的选择
当我在A 行中选择一个值时,我希望B 和C(同一行)根据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',
},
【问题讨论】:
-
请提供一些代码。我们需要了解这些值是如何选择的,哪些代码试图更改这些值,以及它在工作时会发生什么。给我们一些可以合作的东西,这样我们就可以帮助您调试/提出解决方案
-
我已经完成了! :)