[code="java"]{header: "密码", sortable:true, dataIndex:"card_password",renderer:function(value){return ""+value+""}},
{header: "创建者", sortable:true,width: 60, dataIndex:"card_admin",renderer:function(value){return ""+value+""}},
[/code]
我的密码要根据创建者来显示,有些创建者密码要隐藏,这个功能要怎么做啊?
[code="js"]
renderer:function(value, cellMeta, record, rowIndex, columnIndex, store)
{
// 得到创建者信息
var creator = record.data['card_admin'];
// 是否显示密码(boolean)
var isShowPassword = 自己的逻辑判断(creator);
return "<span style='color:#000000;'>"+isShowPassword ? value : ''+"</span>"}
}
// value: 当前的值
// cellMeta: 单元格式ID
// record: 当前行的所有数据
// rowIndex: 当前行的行号(分页后的)
// columnIndex: 列号
// store: 数据集
[/code]
renderer有6个参数:
[quote]* value : Object
The data value for the cell.
metadata : Object
An object in which you may set the following attributes:
o css : String
A CSS class name to add to the cell's TD element.
o attr : String
An HTML attribute definition string to apply to the data container element within the table cell (e.g. 'style="color:red;"').
record : Ext.data.record
The Ext.data.Record from which the data was extracted.
rowIndex : Number
Row index
colIndex : Number
Column index
store : Ext.data.Store
The Ext.data.Store object from which the Record was extracted.[/quote]
第3个参数就是record,用record.get(fieldName)来取其它列的值。例:record.get("card_admin")