easyui的formatter属性的用法

本文介绍如何在EasyUI中实现数据库code字段的转义显示为对应的汉字,并提供了一个具体的示例代码,展示了如何在datagrid组件中应用formatter函数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 背景:

新接手系统页面展示采用easyUI,因为业务调整新增字段,数据库存code,页面想转义展示对应汉字。

2.参照官网:http://www.jeasyui.net/tutorial/28.html

function formatPrice(val,row){
	if (val < 20){
		return '<span style="color:red;">('+val+')</span>';
	} else {
		return val;
	}
}

格式化函数。可是该函数在th那种页面可以使用,在field后面不知道怎么加。

网上看了个例子:

$(document).ready(function() {
		$('#dg').datagrid({
			url : "/bboo/resource/gj-resource!queryResource.do",
			columns : [ [ {
				field : 'resourceId',
				title : '菜单id',
				width : 50,
				sortable : true
			}, {
				field : 'description',
				title : '描述',
				width : 50,
				sortable : true
			}, {
				field : 'name',
				title : '名称',
				width : 50,
				sortable : true
			}, {
				field : 'sort',
				title : '分类',
				width : 50,
				sortable : true
			}, {
				field : 'type',
				title : '类型',
				width : 50,
				sortable : true
			}, {
				field : 'value',
				title : 'url值',
				width : 50,
				sortable : true
			}, {
				field : 'pid',
				title : '父菜单',
				width : 80,
				formatter : function(value, row, index) {
					if (row.parent) {
						return row.parent.resourceId;
					} else {
						return value;
					}
				}
			} ] ]
		});
	});

放到别的位置极有可能提示错误。

**********参开文档如下********************

http://blog.csdn.net/u010523770/article/details/51838989

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

bohu83

买个馒头吃

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值