Results 1 to 10 of 10

Thread: Changing the background colors of the grid cell on update

  1. #1
    Ext User
    Join Date
    Jul 2008
    Posts
    18

    Default Changing the background colors of the grid cell on update

    Hello all,

    I have a scenario where I change the background of the grid cells depending on the incoming update for the cells. Color calculation takes old and new value of the cell as parameters.

    I couldn't see any "cellBeforeUpdate" kind of an event; which event would be the best to implement this?

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    That kind of logic belongs in the column renderer function.

  3. #3
    Ext User
    Join Date
    Jul 2008
    Posts
    18

    Default

    Renderer doesn't tell me existing value so I can compare it to new value and specify the color. I know I can use the rowIndex and colIndex to find the existing value but that is the thing I am trying to avoid since this is a Comet application and updates will be coming continuously. This will be done for only updates btw.

    Still think the renderer is the right place?

  4. #4

    Default

    What about the afteredit event in the EditorGridPanel?

  5. #5
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Can't you use the x-grid3-dirty-cell class for that (which normally shows the red triangle, but you could create a different css rule that colors the field)?

  6. #6
    Ext User
    Join Date
    Jul 2008
    Posts
    18

    Default

    @Condor,
    Nope; color depends on some calculation between old value and new value.

    @ColinBowern,
    My grid is read-only and not editable by user; so it is just a GridPanel. Data comes through some comet server.

  7. #7
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Would it be possible to use a record that contains both old and new values? Writing a renderer is much easier in this case.

  8. #8
    Sencha User realjax's Avatar
    Join Date
    Aug 2009
    Location
    Netherlands
    Posts
    412

    Default

    Or use Gridview. Remove the old row and insert the new one. It listens to the events you need.

  9. #9

    Default

    It seems to me that a column-renderer in the general case must consider only the present value, since it is responsible for creating the grid's appearance the first time (as well as at every other time thereafter). In this case, there is no "previous value."

    If you do need to react to changes, however, then you may need to implement some kind of 'stash' of previous record-values, e.g. setting an event-listener to stuff the information into a hash.

    If you want the changes to happen without redrawing the entire grid, you're definitely taking a trip into monkey-land. You can do it by manipulating the DOM ...

  10. #10
    Sencha User realjax's Avatar
    Join Date
    Aug 2009
    Location
    Netherlands
    Posts
    412

    Default

    yeah.

    Or use Gridview

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •