Announcement

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

    Change row background color dynamically

    SmartGWT version: 3.0

    Browser(s) version(s) involved:
    - Google Chrome: 14.0.835.202 m
    - Mozzila Firefox: v3.6.23

    Hi,

    I have the following scenario:
    1. I create a databound ListGrid.
    2. I push data to the Grid from the server side.
    3. On an update event I update the changed record.

    Now everything so far is fine. What I want to do next is change the background color of the updated row in my ListGrid to red, and seconds later return the style to normal, so the user can see flashes when an updated has occurred.

    I've implemented the following into my onSuccess method of my RPC when an update occurs:

    ...
    int recordNum = keyData.getRecordList().findIndex("key", result.getKey());
    //the right key is returned here.
    keyData.getRecord(recordNum).setCustomStyle("background-color:#FF0000");
    keyData.refreshRow(recordNum);
    //where keyData is my ListRecord

    Now I expect here to see my row's background changing to red, however nothing happens.

    Any way I can do this?

    Thanks.

    #2
    record.customStyle specifies the name of a CSS class, not CSS text directly.

    Comment


      #3
      Hi,

      Thanks for the quick reply.

      This is what I thought initially, so I had this in my module.css file:

      .changedCell {
      background-color:#FF0000;
      }

      and was calling it this way:

      keyData.getRecord(recordNum).setCustomStyle("changedCell");

      (don't know why Im seeing space in the "changedCell", I don't have this in my code)

      So maybe I am putting it in a wrong css file? Are there any other .css files that SmartGWT uses to override the module one?

      Thanks.

      Comment


        #4
        No, we don't specially override your CSS. Most likely, you are not successfully loading the CSS file, have a typo somewhere, or a similar problem.

        Comment


          #5
          Hi,

          So I couldn't figure out why it wasn't loading my class from my css, so I put the style in the <head> tag of the html file and it works fine now.

          Still I did hit another issue.

          When I get an "update" or "remove" operation for a record, changing the color of the row works fine, because a record with this key already exists. However if I get an "add" operation I get a null point exception. Now, I presume this is because of the async nature of gwt, so the record hasn't been added still when Im trying to access it to change the cell color. Is there a workaround this?

          Thanks in advance!

          Comment

          Working...
          X