The Column render is used.
First look:
The Code is as follows:
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> </title>
<Link href = "../extjs-4.1.0/resources/css/ext-all.css" rel = "stylesheet" type = "text/css"/>
<Script src = "../extjs-4.1.0/bootstrap. js" type = "text/javascript"> </script>
<Style type = "text/css">
X-grid-cell.user-online
{
Background-color: # 9fc;
}
X-grid-cell.user-offline
{
Background-color: blue;
}
</Style>
<Script type = "text/javascript">
Ext. onReady (function (){
Ext. widget ('grid ',{
Title: 'users ',
Store :{
Fields: ['name', 'email ', 'online'],
Data :[
{'Name': 'wang junwei ', 'email': 'wangjunwei1 @ 163.com ', 'online': true },
{'Name': 'wang junwei 1 ', 'email': 'wangjunwei2 @ 163.com ', 'online': false },
{'Name': 'wang junwei 2', 'email ': 'wangjunwei3 @ 163.com', 'online': false },
{'Name': 'wang junwei 3', 'email ': 'wangjunwei4 @ 163.com', 'online': true}
]
},
Columns :[
{
Header: 'name ',
DataIndex: 'name ',
Renderer: function (value, meta, record ){
Meta. tdCls = record. get ("online ")? 'User-online': 'user-offline ';
Return value;
}
},
{Header: 'email ', dataIndex: 'email', flex: 1 },
{Header: 'online', dataIndex: 'online '}
],
Width: 400,
RenderTo: Ext. getBody ()
});
});
</Script>
</Head>
<Body>
</Body>
</Html>