ListGrid: set background color of a specific row

Hi,

I would like to change the background color of the selected row (double click).

The following code does not work.

overviewList.addRecordDoubleClickHandler(new RecordDoubleClickHandler() {
   public void onRecordDoubleClick(RecordDoubleClickEvent event) {
      event.getRecord().setAttribute("STYLE", "background-color:#FF0000;");
   }
});

I would like to use setAlternateRecordStyles(true) as well.

Thanks a lot for your help!

There is already a distinct CSS style for the selected row, just modify that. If you’re trying to represent something other than selection, you can also add a “customStyle” attribute to the ListGridRecord itself to have it use a custom style.

ListGridRecord: set background color of a specific row

Is it possible to do the same thing with ListGridRecord ?

I tried this code but is not working :

listGridRecord.setAttribute("customStyle", "background-color:#FF0000");

customStyle should be the name of a CSS style, not CSS text directly.

Hello Isomorphic,

setting customStyle to a custom CSS class works fine. But there is a little problem. The customStyle overwrites the default SmartGWT cell style. I found out that the default style class for my cells assigned by SmartGWT is “tallCell”. I then tried to do the following: setCustomStyle(“tallCell highlightedCell”) to assign both the default and custom class to the row, where highlightedCell is my custom CSS class (it contains: background-color: yellow). But the result is somewhat buggy, the row color is not changed until I hover over the record with my mouse.

I had to override getBaseStyle of the ListGrid like here: http://www.smartclient.com/smartgwt/showcase/#grid_appearance_hilite_replace . It works fine now!