ExtJS4 Grid改變單元格背景顏色及Column render學習
更新時間:2013年02月06日 11:26:14 作者:
利用的是Column的render實現(xiàn)單元格背景顏色改變,本文給予了實現(xiàn)代碼,感興趣的朋友可以了解下,或許對你學習ExtJS4 Grid有所幫助
利用的是Column的render
先看效果圖:
代碼如下:
復制代碼 代碼如下:
<!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': '王俊偉', 'email': 'wangjunwei1@163.com', 'online': true },
{ 'name': '王俊偉1', 'email': 'wangjunwei2@163.com', 'online': false },
{ 'name': '王俊偉2', 'email': 'wangjunwei3@163.com', 'online': false },
{ 'name': '王俊偉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>
相關(guān)文章
Extjs407 getValue()和getRawValue()區(qū)別介紹
mydate.getvalue() 返回的是對象;mydate.getRawValue() 返回的是該控件的顯示值,不知道的朋友可以參考下哈2013-05-05Extjs學習筆記之一 初識Extjs之MessageBox
去官網(wǎng)下載好extjs的壓縮包,解壓縮之后得到如下目錄結(jié)構(gòu)。2010-01-01ExtJS Grid使用SimpleStore、多選框的方法
ExtJS 中Grid使用SimpleStore、多選框的方法,需要的朋友可以參考下。2009-11-11extjs grid取到數(shù)據(jù)而不顯示的解決
在使用extjs gridpanel時,當將數(shù)據(jù)載入時,grid中的數(shù)據(jù)并沒有顯示出來。2008-12-12Extjs4 GridPanel的主要配置參數(shù)詳細介紹
主要配置項:store:表格的數(shù)據(jù)集、columns:表格列模式的配置數(shù)組,可自動創(chuàng)建ColumnModel列模式等等2013-04-04Extjs4 Treegrid 使用心得分享(經(jīng)驗篇)
最近調(diào)試EXTJS 4的treegrid實例,看了很多水友的文章,以及官方的demo,沒一個可靠的,于是乎自己折騰中...感興趣的朋友可以了解下本文或許對你有所幫助2013-07-07