ext.net中Gridpanel的renderer参数

参考: http://blog.csdn.net/yangxiaojun9238/article/details/8240139

 

用法样例:

<ext:Column ColumnID="DV_ACTUAL" Header="头部标题" Width="80" DataIndex="DV_ACTUAL"
                            Resizable="true" MenuDisabled="true" Sortable="false" Hideable="false">
                            <Renderer FormatArgs="value,cellmeta, record,rowIndex,columnIndex,store" Fn="showActualDamageRatio" />
                        </ext:Column>

  

 

FormatArgs 代表了Fn所需要的参数。比如这里Fn的处理函数为 showActualDamageRatio, 我们可以定义如下函数:
        var showActualDamageRatio = function (value, cellmeta, record, rowIndex, columnIndex, store) {
            if (record.data.STATUS == "未解决" || record.data.STATUS == "处理中") {
                return '<span style=color:blue;>0.0</span>';
            }
            else {
                return '<span style=color:blue;>' + value + '</span>';
            }

        }
    </script>

  

参考API说明:fn : Function
The function to use to process the cell""s raw data to return HTML markup for the grid view. The render function is called with the following parameters:
1、value : Object
The data value for the cell.(当前单位格的值)
2、metadata : Object
An object in which you may set the following attributes一个可以设置下边两个属性的对象)
**css : String
A CSS class name to add to the cell""s TD element.
(给单位格的TD元素设置CSS的class名称)
**attr : String
An HTML attribute definition string to apply to the data container element within the table cell (e.g. ""style="color:red;""").
(给单位格元素增长一个html的属性)
3、record : Ext.data.record 
The Ext.data.Record which the data was extracted.
(该字段地点行对应的Ext.data.Record对象(整笔记录))

获取数据可以这样写:record.data["name"]
4、rowIndex : Number
Row index(行号)
5、colIndex : Number
Column index(列号)
6、store : Ext.data.Store
The Ext.data.Store object which the Record was extracted.
(数据源对象就是Grid的store/ds)

renderer:function(value, cellmeta, record, rowIndex, columnIndex, store){

}

posted @ 2014-06-28 23:33  st_gloden  阅读(1961)  评论(0编辑  收藏  举报