extjs render 用法介紹_extjs
May 16, 2016 pm 05:22 PM
extjs
render
複製程式碼 程式碼如下:
var cm = new Ext.grid.ColumnModel(
[
new Ext.grid.RowNumberer({ header: "", width: 20, align: 'center' }),
{ header: '', align: 'center', dataIndex: 'AccountAndRoseID', width: 50, sortable: true, hidden: true },
{ header: '', align: 'center', dataIndex: 'UserAccountId', width: 50, sortable: true, hidden: true },
{ header : '帳號', align: 'center', dataIndex: 'UserAccountName', width: 200, sortable: true },
{ header: '角色名稱', align: 'center', dataIndex: 'UserRoleName', width : 200, sortable: true },
{ header: '狀態', align: 'center', dataIndex: 'UserAccountStateId', width: 200, sortable: true, hidden: true, renderer: function() }
]
renderer可以格式化該列顯示的資料格式或按照你自訂的腳本顯示最終資料樣子(我目前是這麼理解的)
先看下renderer: function( )裡的參數
複製程式碼 程式碼如下:
renderer:function(function,function( record, rowIndex, columnIndex, store){
}
1.value是目前單元格的值
2.cellmeta裡面保存的是cellId單元格id,id不知道是乾啥的,似乎是列號,css是這個單元格的css樣式。
3.record是這行的所有數據,你想要什麼,record.data["id"]這樣就獲得了。
4.rowIndex是行號,不是從頭往下數的意思,而是計算了分頁以後的結果。
5.columnIndex列號太簡單了。
6.store,這個厲害,實際上這個是你構造表格時候傳遞的ds,也就是說表格裡所有的數據,你都可以隨便調用,唉,太厲害了。
網路上找到一篇博文,非常不錯,直觀明了:
複製程式碼 程式碼
複製程式碼 程式碼<html>
<meta http-equiv="Content-Type" c>
<title>03.grid</title>
<link rel="stylesheet" type="text/css" href="http://www.cnblogs.com/../resources/css/ext-all.css" />
<script type="text/javascript" src="http://www.cnblogs.com/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="http://www.cnblogs.com/ext-all.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
/*
var cm = new Ext.grid.ColumnModel([
{header:'编号',dataIndex:'id'},
{header:'性别',dataIndex:'sex',renderer:function(value){
if (value == 'male') {
return "<span style='color:red;font- Weight:bold;'>红男</span>";
} else {
return "<span style='color:green;font-weight:bold;'>绿女< /span>";
}
}},
{header:'名前',dataIndex:'name'},
{header:'説明',dataIndex:'descn'}
]);
*/
function renderSex(value) {
if (value == 'male') {
return "<span style='color:red;font-weight:ボールド;'>红男</span><img src='user_male.png' />";
} else {
return "<span style='color:green;font- Weight:bold;'>绿女</span><img src='user_girl.png' />";
}
}
function renderDescn(value, cellmeta, Record、rowIndex、columnIndex、store) {
var str = "<input type='button' value='查看详细信息' >";
return
}
var cm = new Ext.grid.ColumnModel([
{header:'编号',dataIndex:'id'},
{header:'性别',dataIndex:'sex',renderer:renderSex},
{header:'名前',dataIndex:'name'},
{header:'説明',dataIndex:'descn',renderer:renderDescn}
]);
var data = [
['1','male','name1','descn1'],
['2','女性','name2','descn2' ]、
['3'、'男性'、'名前3'、'説明3']、
['4'、'女性'、'名前4'、'説明4']、
['5 ','男性','name5','descn5']
];
var store = new Ext.data.Store({
プロキシ: new Ext.data.MemoryProxy(data),
リーダー: new Ext.data.ArrayReader({}, [
>{名前: 'id'}、
{名前: '性別'}、
{名前: '名前'}、
{名前: '説明'}
])
} );
store.load();
var Grid = new Ext.grid.GridPanel({
autoHeight: true,
renderTo: 'grid',
store: store,
cm: cm
} );
});
</script>
</head>
<script type="text/javascript" src="../examples.js"></script>
<div id="grid"></div>
</body>
</html>
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱門文章
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 週前
By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
擊敗分裂小說需要多長時間?
3 週前
By DDD
公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?
3 週前
By 王林

熱門文章
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 週前
By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
擊敗分裂小說需要多長時間?
3 週前
By DDD
公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?
3 週前
By 王林

熱門文章標籤

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

Mpeppe(MPEPE)幣:加密貨幣市場的新競爭者,吸引來自 Render(RNDR)和網路電腦(ICP)的投資者

HMD Slate Tab 5G 洩漏為中階平板電腦,搭載 Snapdragon 7s Gen 2、10.6 吋顯示器和 Lumia 設計
