简体   繁体   English

如何根据复选框更改网格栅格角度的行颜色?

[英]How to change row color in ag-grid angular based on checkbox?

There are multiple checkboxes in a single row. 单行中有多个复选框。 The color of row should change based on the checkbox I check. 行的颜色应根据我选中的复选框而更改。

From the picture, suppose I check cell-(1,1) the color should be red or something.. If I check the cell(1,2) - another color. 从图片中,假设我检查单元格(1,1)的颜色应该是红色或其他颜色。如果我检查单元格(1,2)-另一种颜色。 If I check the cell(1,3) - another color. 如果我检查单元格(1,3)-另一种颜色。

table with checkbox in each cell 每个单元格中带有复选框的表格

One of the solutions could be to change the "cellStye" of all the columns when clicking the cell's checkbox. 解决方案之一是在单击单元格的复选框时更改所有列的"cellStye" You can get the information from ag-grid docs [ https://www.ag-grid.com/javascript-grid-cell-styles/#cell-style] . 您可以从ag-grid文档[ https://www.ag-grid.com/javascript-grid-cell-styles/#cell-style]获取信息。

I have implemented a basic functionality which demonstrates your need. 我已经实现了演示您的需求的基本功能。 See the following plunkr - 请参阅以下plunkr-

https://next.plnkr.co/edit/n3Jc8jZWtOc4FVd4 https://next.plnkr.co/edit/n3Jc8jZWtOc4FVd4

It will give you an idea of how to implement it. 它将使您了解如何实现它。 Please update your code as per your logic. 请根据您的逻辑更新代码。 The goal is to demonstrate how to change the row color on the cell's checkbox click. 目的是演示如何更改单元格复选框上的行颜色。 Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM