View Full Version : Changing the background colors of the grid cell on update

23 Dec 2009, 7:24 AM
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?

23 Dec 2009, 7:33 AM
That kind of logic belongs in the column renderer function.

23 Dec 2009, 8:26 AM
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?

23 Dec 2009, 10:05 AM
What about the afteredit event in the EditorGridPanel?

23 Dec 2009, 11:48 AM
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)?

23 Dec 2009, 12:28 PM
Nope; color depends on some calculation between old value and new value.

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

23 Dec 2009, 11:12 PM
Would it be possible to use a record that contains both old and new values? Writing a renderer is much easier in this case.

24 Dec 2009, 4:25 AM
Or use Gridview. Remove the old row and insert the new one. It listens to the events you need.

Mike Robinson
24 Dec 2009, 7:14 AM
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 ...

24 Dec 2009, 8:31 AM

Or use Gridview