jquery EasyUI的formatter格式化函数代码
2018-10-12 14:01
901 查看
要格式化数据表格列,需要设置formatter属性,该属性是一个函数,它包含两个参数:
value: 对应字段的当前列的值
record: 当前行的记录数据
对于数字的格式化,可以使用javascript提供的对数字格式化的方法
输出:
2.44
value: 对应字段的当前列的值
record: 当前行的记录数据
$('#tt').datagrid({
title:'Formatting Columns',
width:550,
height:250,
url:'datagrid_data.json',
columns:[[
{field:'itemid',title:'Item ID',width:80},
{field:'productid',title:'Product ID',width:80},
{field:'listprice',title:'List Price',width:80,align:'right',
formatter:function(val,rec){
if (val < 20){
return '<span style="color:red;">('+val+')</span>';
} else {
return val;
}
}
},
{field:'unitcost',title:'Unit Cost',width:80,align:'right'},
{field:'attr1',title:'Attribute',width:100},
{field:'status',title:'Status',width:60}
]]
});
对于数字的格式化,可以使用javascript提供的对数字格式化的方法
var num=2.4445;
var number=val.toFixed(2);//格式化,保留两位小数
alert(number);
输出:
2.44
您可能感兴趣的文章:
相关文章推荐
- jquery EasyUI的formatter格式化函数代码
- jquery EasyUI的formatter格式化函数代码
- jquery EasyUI的formatter格式化函数代码
- jquery EasyUI的formatter格式化函数代码
- 团队开发之:eclipse自动格式化代码formatter使用方式
- js 数值项目的格式化函数代码
- 《thinking in java》笔记16 -类似C中printf()的格式化输出函数 和 Formatter
- asp中格式化HTML函数代码 SDCMS加强版
- Java String 函数常用操作 & format() 格式化输出,代码详解
- jQuery EasyUI DataGrid - 格式化列(formatter )
- FormatRemoteUrl函数之asp实现格式化成当前网站完整的URL-将相对地址转换为绝对地址的代码
- python 堆、队列操作、字符串格式化输出、字符串常用函数 示例代码
- Date对象格式化函数代码
- js 数值项目的格式化函数代码
- php格式化json函数示例代码
- JavaScript格式化数字的函数代码
- jQuery EasyUI DataGrid - 格式化列(formatter )
- jdt.core.formatter.CodeFormatter格式化java代码
- 调用 FormatEx 函数格式化磁盘的代码