Ag-grid 如何通过单击按钮更新单元格样式
Ag-grid how to update cell style by clicking a button
我的网格顶部有一个按钮,我想在单击后根据单元格值更新单元格样式。我有一些工作但它更新所有列而不是特定单元格。单击按钮时如何 update/target 特定单元格。
updateCellStyle(){ this.gridApi.getColumnDef(column).cellStyle = { border: '1px solid #165a9f' }}
我还没有测试过,但我相信它是这样的;单击按钮时将 buttonClicked
设置为 true。
const gridOptions = {
....
context: {
buttonClicked: false
}
};
列Def:
cellStyle: params => params.context.buttonClicked && params.value > 80 ?
{ border: '1px solid #165a9f' } : { border: 'whatever it is before the button is clicked' }
我的网格顶部有一个按钮,我想在单击后根据单元格值更新单元格样式。我有一些工作但它更新所有列而不是特定单元格。单击按钮时如何 update/target 特定单元格。
updateCellStyle(){ this.gridApi.getColumnDef(column).cellStyle = { border: '1px solid #165a9f' }}
我还没有测试过,但我相信它是这样的;单击按钮时将 buttonClicked
设置为 true。
const gridOptions = {
....
context: {
buttonClicked: false
}
};
列Def:
cellStyle: params => params.context.buttonClicked && params.value > 80 ?
{ border: '1px solid #165a9f' } : { border: 'whatever it is before the button is clicked' }