Gridpanel: change cell's css class on click (eg. toggle the cell background color)

  1. #1

    Gridpanel: change cell's css class on click (eg. toggle the cell background color)

    Hi
    In my Gridpanel I would like a cell's background color to toggle every time it is clicked (eg. white to green on first click, green to white on next click, etc).

    I presume altering the cell's css class (either changing from one class to another, or adding/removing an extra class) would be the best way to do this but I can't get it working dynamically. (I have also tried toggling the Dirty property of the cell to achieve the same effect but could not get this working either). I am using a CellSelectionModel but that only affects the currently selected cell and i would like the cells to keep their color status after being clicked, eg:
    Click image for larger version. 

Name:	nodes-selected.png 
Views:	389 
Size:	4.2 KB 
ID:	4453

    I have found a few examples involving column renderers or Ext.fly but are for version 1 and I can't get them working for version 2. eg:
    http://forums.ext.net/showthread.php...ter-row-select
    http://forums.ext.net/showthread.php...with-DataIndex
    http://forums.ext.net/showthread.php...ngle-in-corner

    If anyone could show me how to toggle a cell's background color on a cell click I would be very grateful.
    Thanks.
  2. #2
    Ok, based on the version 2 Demo example: https://examples2.ext.net/#/GridPane...Configuration/

    I can now change the text color of the items in the column that was clicked (but not just the cell). I can also change the background color of the associated <span> but this looks very clipped and would look much more effective if the whole cell background color was changed.

    Does anyone know how I can limit the renderer to change only the single cell that was clicked, and to alter the cell's style/css rather than the style of the value in the <span>?

    Thanks.

Similar Threads

  1. How to Background color to the cell in Tree grid
    By rajputamit in forum 1.x Help
    Replies: 2
    Last Post: May 06, 2012, 4:16 PM
  2. Replies: 2
    Last Post: Mar 02, 2012, 1:07 PM
  3. [CLOSED] Change grid cell color
    By BGeorge in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Dec 12, 2011, 5:05 AM
  4. [CLOSED] Change grid cell color on fly
    By 78fede78 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 03, 2010, 1:27 PM
  5. Change Cell background depending on value
    By GijsZePa in forum 1.x Help
    Replies: 2
    Last Post: Apr 06, 2010, 3:58 AM

Tags for this Thread

Posting Permissions