jQuery MiniUI自定义单元格
Posted Blogger
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jQuery MiniUI自定义单元格相关的知识,希望对你有一定的参考价值。
监听处理"drawcell"事件
使用"drawcell"事件,可以自定义单元格内容、样式、行样式等。
grid.on("drawcell", function (e) { var record = e.record, column = e.column, field = e.field, value = e.value; //格式化日期 if (field == "birthday") { if (mini.isDate(value)) e.cellhtml = mini.formatDate(value, "yyyy-MM-dd"); } //给年龄,增加"岁"字符串 if (field == "age") { e.cellHtml = value + "岁"; } //给帐号列,增加背景色 if (field == "loginname") { e.cellStyle = "background:#ecedef"; } //超过1万工资,红色标识 if (field == "salary" && value >= 10000) { e.cellStyle = "color:red;font-weight:bold;"; } //显示学历 if (field == "educational") { for (var i = 0, l = Educationals.length; i < l; i++) { var edu = Educationals[i]; if (edu.id == value) { e.cellHtml = edu.name; break; } } } //action列,超连接操作按钮 if (column.name == "action") { e.cellStyle = "text-align:center"; e.cellHtml = ‘<a href="javascript:edit(\‘‘ + record.id + ‘\‘)">Edit</a> ‘ + ‘<a href="javascript:del(\‘‘ + record.id + ‘\‘)">Delete</a>‘ } //将性别文本替换成图片 if (column.field == "gender") { if (e.value == 1) { e.cellHtml = "<span class=‘icon-female‘></span>" } else { e.cellHtml = "<span class=‘icon-boy‘></span>" } } //设置行样式 if (record.gender == 1) { e.rowCls = "myrow"; } });
原文:http://www.miniui.com/docs/tutorial/datagrid_drawcell.html
function onDrawCell(e){ var node = e.node, column = e.column, field = e.field, value = e.value; //格式化日期 if (field == "Finish") { if (mini.isDate(value)) e.cellHtml = mini.formatDate(value, "yyyy年MM月dd日"); } //工期 if (field == "Duration") { e.cellHtml = value + "天"; } //进度 if (field == "PercentComplete") { e.cellHtml = ‘<div class="progressbar">‘ + ‘<div class="progressbar-percent" style="width:‘ + value + ‘%;"></div>‘ + ‘<div class="progressbar-label">‘ + value + ‘%</div>‘ +‘</div>‘; } };
原文:http://www.miniui.com/docs/tutorial/treegrid_drawcell.html
以上是关于jQuery MiniUI自定义单元格的主要内容,如果未能解决你的问题,请参考以下文章
miniui怎么设置单元格的editor属性都有哪些,怎么用js设置
POI 使用XSSF导出Excel自定义单元格颜色为啥始终是黑色的?代码如下