天天看点

jqGrid 中formatter:function参数详解

1 formatter属性

formatter属性支持自定义单元格内容。(因此可以在return 拼接html格式代码)

语法:

formatter:function(cellvalue,options,rowObject){
    return "";
}
           

参数详解:

(1)cellvalue,当前单元格的值

(2)options,该cell的options设置,包括{rowId, colModel,pos,gid}

(3)rowObject,当前cell所在row的值,是一个对象

2 cellvalue

给当前值以%结尾。

formatter:function(cellvalue,options,rowObject){
    return cellvalue+"%";
}
           

3 options

formatter:function(cellvalue,options,rowObject){
    return "<a onclick='ShowRow(\"+options.rowId+\")'>查看详情</a>";
}
           

4 rowObject

formatter:function(cellvalue,options,rowObject){
    return "<a onclick='ShowRow(\"+rowObject.username+\")'>查看详情</a>";
}
           

5 date

将日期类型的值转换为指定格式的字符串。

formatter: 'date', 
formatoptions: { 
           srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' 
}
           

继续阅读