码迷,mamicode.com
首页 > 其他好文 > 详细

EasyUI DataGrid onBeforeRender 使用记录

时间:2015-01-13 17:55:10      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:

有时候会想在视图渲染之前修改表格数据,比如说:sex属性为“1”时,页面显示“男”;“0”时页面则显示为“女”。

那么我们知道,DataGrid 在onLoadSuccess时已经对页面渲染完毕,此时则无法对数据再进行修改,所以API又提供了 onBeforeRender 这个事件。

技术分享

使用示例:

1、将此段代码附加在DataGrid初始化后执行,即可完成在DataGrid渲染之前进行操作

$('#grid').datagrid("options").view.onBeforeRender = function (target, rows) {
	$.each(rows, function (index, row) {
		row.sex = formatSex(row.sex);
	});
};
2、formatSex函数代码
// 格式化性别
function formatSex(sex) {
	if (typeof(sex) != "undefined") {
		if (sex== "1") {
			return "男";
		} else if (sex== "0") {
			return "女";
		}
	}
	return sex;
}


EasyUI DataGrid onBeforeRender 使用记录

标签:

原文地址:http://blog.csdn.net/for_china2012/article/details/42677599

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!