简体   繁体   English

如何更改 gwt-ext 网格中选定行的颜色?

[英]How to change the color of selected row in gwt-ext grid?

I am want to change the color of selected row of grid (gwt-ext grid) in my application.我想在我的应用程序中更改所选网格行(gwt-ext 网格)的颜色。

For this I have done this:为此,我这样做了:

int rowIndex = getGrid().getStore().indexOf(rec);
Element currentRow = getGrid().getView().getRow(rowIndex);
currentRow.getStyle().setProperty("backgroundColor","red");

But it is permanently changing the color of the row.As I select on another row it previous selected row should be in it previous color.但它会永久改变行的颜色。因为我在另一行上的 select 之前选择的行应该是之前的颜色。

So I am not getting what to do the change the color of selected row in the gwt-ext grid.所以我不知道如何更改 gwt-ext 网格中选定行的颜色。

I also want to know how to change the text color of the grid row?我也想知道如何改变网格行的文字颜色?

  1. I think the right was is to add (or modify the existing) css class for the row and not to make this in your java code.我认为正确的是为该行添加(或修改现有的)css class,而不是在您的 java 代码中进行此操作。 The class can you add with addStyleName("myClass") .您可以使用addStyleName("myClass")添加 class 。
  2. Alternative (but wrong for me) - you can reset the color for all rows before you set the color for the selected row.替代方案(但对我来说是错误的) - 您可以在为所选行设置颜色之前重置所有行的颜色。

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

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