Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    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.

    Code:
    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!

    #2
    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.

    Comment


      #3
      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 :
      Code:
      listGridRecord.setAttribute("customStyle", "background-color:#FF0000");

      Comment


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

        Comment


          #5
          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.
          Last edited by jballh; 22 Jul 2009, 04:23.

          Comment


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

            Comment

            Working...
            X