ExtJS4 Grid改變單元格背景顏色及Column render學(xué)習(xí)
更新時(shí)間:2013年02月06日 11:26:14 作者:
利用的是Column的render實(shí)現(xiàn)單元格背景顏色改變,本文給予了實(shí)現(xiàn)代碼,感興趣的朋友可以了解下,或許對(duì)你學(xué)習(xí)ExtJS4 Grid有所幫助
利用的是Column的render
先看效果圖:
代碼如下:
復(fù)制代碼 代碼如下:
<!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() 返回的是對(duì)象;mydate.getRawValue() 返回的是該控件的顯示值,不知道的朋友可以參考下哈2013-05-05Extjs學(xué)習(xí)筆記之一 初識(shí)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í),當(dāng)將數(shù)據(jù)載入時(shí),grid中的數(shù)據(jù)并沒有顯示出來。2008-12-12Extjs4 GridPanel的主要配置參數(shù)詳細(xì)介紹
主要配置項(xiàng):store:表格的數(shù)據(jù)集、columns:表格列模式的配置數(shù)組,可自動(dòng)創(chuàng)建ColumnModel列模式等等2013-04-04ExtJS下書寫動(dòng)態(tài)生成的xml(兼容火狐)
ExtJS下書寫動(dòng)態(tài)生成的xml,只能有IE可以運(yùn)行,為了兼容性,必須考慮火狐的用戶,所以,這個(gè)程序?yàn)榱耍夯鸷脩舻募嫒菪?/div> 2013-04-04Extjs4 Treegrid 使用心得分享(經(jīng)驗(yàn)篇)
最近調(diào)試EXTJS 4的treegrid實(shí)例,看了很多水友的文章,以及官方的demo,沒一個(gè)可靠的,于是乎自己折騰中...感興趣的朋友可以了解下本文或許對(duì)你有所幫助2013-07-07最新評(píng)論