-
20 May 2008 8:26 AM #1zhiliangGuest
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
-
20 May 2008 11:45 AM #2
Instead of doing .css = 'foo', try this...
Just a shot in the dark. Someone else please correct me if I'm wrong. Cheers.Code:myGrid.getColumnModel().getColumnById('status).addClass('redbg');Noah
Senior Web Developer
NBA.com
-
20 May 2008 3:21 PM #3
You might want to check the Grid FAQ and the example in my signature, examples of this in both.
MJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow
-
21 May 2008 1:26 AM #4zhiliangGuest
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( );
}


Reply With Quote