[CLOSED] GridPanel Cell Color Renderer

  1. #1

    [CLOSED] GridPanel Cell Color Renderer

    I have a renderer defined for select columns in a GridPanel as follows:
    var linkRenderer = function (value, meta, record, index) {
    	if (value != 0) {
    		return Ext.String.format("<a class='company-link' href='#' onclick='linkClick({1},{2});'>{0}</a>", value, index, meta.columnIndex);
    	}
    	else {
    		return value;
    	}
    };
    I'm trying to modify it to also change the cell background color like this:
    var linkRenderer = function (value, meta, record, index) {
    	if (value != 0) {
    		metadata.tdCls = "tdRed";
    		return Ext.String.format("<a class='company-link' href='#' onclick='linkClick({1},{2});'>{0}</a>", value, index, meta.columnIndex);
    	}
    	else {
    		metadata.tdCls = "tdGreen";
    		return value;
    	}
    };
    This is the CSS:
    .x-grid-row .tdRed {
    	background-color: #FF0000;
    }
    .x-grid-row .tdAmber {
    	background-color: #FF9933;
    }
    .x-grid-row .tdGreen {
    	background-color: #00CC00;
    }
    .x-grid-custom .company-link
    {
    	color: #0000FF;
    }
    But it doesn't work; the cell is just blank. What am I missing?
    Last edited by Baidaly; Nov 04, 2013 at 7:10 PM. Reason: [CLOSED]
  2. #2
    Never mind, I'm an idiot.

    var linkRenderer = function (value, meta, record, index) {
    	if (value != 0) {
    		meta.tdCls = "tdRed";
    		return Ext.String.format("<a class='company-link' href='#' onclick='linkClick({1},{2});'>{0}</a>", value, index, meta.columnIndex);
    	}
    	else {
    		meta.tdCls = "tdGreen";
    		return value;
    	}
    };
    I was using the variable "metadata" instead of "meta" because I copied from a different example.
  3. #3
    Hi,

    I recommend to use ScriptMode="Development". In that case you would see an error message in a browser's console and fix the problem even more quickly.

Similar Threads

  1. Change GridPanel Cell background color
    By mis@adphk.com in forum 2.x Help
    Replies: 1
    Last Post: Mar 19, 2013, 1:43 AM
  2. [CLOSED] Gridpanel cell background color
    By mis@adphk.com in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 13, 2013, 2:00 AM
  3. Replies: 3
    Last Post: Feb 14, 2013, 10:35 AM
  4. Replies: 1
    Last Post: Jul 10, 2012, 11:16 AM
  5. Gridpanel cell color
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Nov 20, 2008, 11:00 AM

Tags for this Thread

Posting Permissions