1. #1
    zhiliang
    Guest

    Default dynamic change column color for grid

    dynamic change column color for grid


    hi, i have a grid and i need to change the color of one column dynamically

    {
    header: "Status",
    dataIndex: 'Status',
    width: 80,
    renderer: renderStatus,
    editor: myComboStatusForGrid
    },

    i define the renderer to set the text color of this column:

    function renderStatus(data, cell, record, rowIndex, columnIndex, store){
    switch(data) {
    case "Pending":
    cell.css = "orangetext";
    return "Pending";
    case "Passed":
    cell.css = "greentext";
    return "Passed";
    case "Failed":
    cell.css = "redtext";
    return "Failed";
    case "Obsolete":
    cell.css = "graytext";
    return "Obsolete";
    }
    };

    in css:

    .redtext {color: #FF0000 !important;}
    .yellowtext {color: #FFFF00 !important;}
    .greentext {color: #00CC00 !important;}
    .graytext {color: #808080 !important;}
    .orangetext {color: #FF9900 !important;}


    this works well, but i also need to change the background color of this column based on different profile:


    function login(){
    var profile;

    if(profile ='admin')
    {
    //set the bg color = red
    //myGrid.getColumnModel().getColumnById('Status').css= "redbg";
    }
    else if(profile = 'manage')
    {
    //set bg color = green
    }
    }
    anyone know how to change the dynamic bg color ?? thx

  2. #2
    Ext JS Premium Member NoahK17's Avatar
    Join Date
    Apr 2008
    Location
    Atlanta, GA
    Posts
    518
    Vote Rating
    1
    NoahK17 is on a distinguished road

      0  

    Default


    Instead of doing .css = 'foo', try this...

    Code:
    myGrid.getColumnModel().getColumnById('status).addClass('redbg');
    Just a shot in the dark. Someone else please correct me if I'm wrong. Cheers.
    Noah
    Senior Web Developer
    NBA.com

  3. #3
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    You might want to check the Grid FAQ and the example in my signature, examples of this in both.

  4. #4
    zhiliang
    Guest

    Default


    i think the method is not really good, but it works


    function renderForProfile(data, cell, record, rowIndex, columnIndex, store){
    switch(profile){
    case'admin':
    cell.css =
    "graycell";
    return data;
    case'':
    cell.css =
    "pinkcell";
    return data;
    case'manager':
    cell.css =
    "graycell";
    return data;
    }

    };


    function login(){


    myNeoGrid.getColumnModel().setRenderer(6,renderForProfile);


    myNeoGrid.getView().refresh( );



    }

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi