EasyUI表格DataGrid格式化formatter用法
1.通过HTML标签创建数据表格时使用formatter
<!DOCTYPE html>
<html> <head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="jquery-easyui-1.5.1/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="jquery-easyui-1.5.1/themes/icon.css">
<script type="text/javascript" src="jquery-easyui-1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var data = {
"rows": [{
"stuName": "李斯",
"stuAge": 23
}, {
"stuName": "白起",
"stuAge": 25
}],
"total": 2
}
$('#tt').datagrid('loadData',data);
}) //value:字段值;row:行记录数据;index: 行索引
function formatPrice(value,row,index) {
if(value>=20){
return '<span style="color:blue;">' + value + '</span>';
}
}
</script>
</head> <body>
<table id="tt" title="studentInfo" class="easyui-datagrid" style="width:300px;height:250px">
<thead>
<tr>
<th field="stuName" width="80">学生姓名</th>
<th field="stuAge" width="80" formatter="formatPrice">学生年龄</th>
</tr>
</thead>
</table>
</body> </html>
2.通过JS创建数据表格时使用formatter
<!DOCTYPE html>
<html> <head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="jquery-easyui-1.5.1/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="jquery-easyui-1.5.1/themes/icon.css">
<script type="text/javascript" src="jquery-easyui-1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var data = {
"rows": [{
"stuName": "李斯",
"stuAge": 23
}, {
"stuName": "白起",
"stuAge": 25
}],
"total": 2
} $("#tt").datagrid({
columns: [
[{
field: 'stuName',
title: '学生姓名',
width: 80
},
{
field: 'stuAge',
title: '学生年龄',
width: 80,
formatter: function(value, row, index) {
if(value >= 20) {
return '<span style="color:blue;">' + value + '</span>';
}
}
}
]
] }).datagrid('loadData', data);
})
</script>
</head> <body>
<table id="tt" title="studentInfo" style="width:300px;height:250px"></table>
</body> </html>
EasyUI表格DataGrid格式化formatter用法的更多相关文章
- easyui之datagrid之formatter(后台传递常量自动转换值)
1,datagrid之formatter formatter格式化函数有三个参数: value:字段值(一般为后台传递给前台的值): row:当前行数据: index:当前行索引. return值是显 ...
- EasyUI中datagrid的基本用法
EasyUI中datagrid是最常用的一个控件了,现在整理一下datagrid的基本语法,先展示下页面效果吧,如下图
- EasyUI表格DataGrid前端分页和后端分页的总结
Demo简介 Demo使用Java.Servlet为后台代码(数据库已添加数据),前端使用EasyUI框架,后台直接返回JSON数据给页面 1.配置Web.xml文件 <?xml version ...
- EasyUI表格DataGrid获取数据的方式
第一种方式:直接返回JSON数据 package com.easyuijson.util; import java.text.SimpleDateFormat; import net.sf.js ...
- easyUI中 datagrid 格式化日期
$('#List').datagrid({ url: '@Url.Action("GetList")', width:SetGridWidthSub(10), methord: ' ...
- 第二百二十二节,jQuery EasyUI,DataGrid(数据表格)组件
jQuery EasyUI,DataGrid(数据表格)组件 学习要点: 1.加载方式 2.分页功能 本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于 Pa ...
- EasyUI 的DataGrid中DateTime的格式化问题
想必用过EasyUI的朋友们都应该会遇到这样的情况吧:(下图) 在EasyUI中DataGrid中如果要显示DateTime的时间时候,便会显示上图这样的格式,很明显,这里的格式不会是我们想要的,我们 ...
- easyUI的datagrid表格的使用
实现easyUI表格的里面数据的增删改查功能.SQL使用Oracle和mybatis. 话不多说,直接上代码. 首先是前段部分的. var session = GetSession(); var pa ...
- easyUI 数据表格datagrid的使用
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
随机推荐
- Linux 文件删除原理_009
***了解Linux文件删除原理先了解一下文件inode索引节点,每个文件在Linux系统里都有唯一的索引节点(身份证号) inode.如果文件存在硬链接,那这个文件和这个文件的硬链接的inode是相 ...
- dubbo+spring_maven 遇到的问题 Error creating bean with name '***': Instantiation of bean failed;
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error ...
- Hive学习笔记——安装和内部表CRUD
1.首先需要安装Hadoop和Hive 安装的时候参考 http://blog.csdn.net/jdplus/article/details/46493553 安装的版本是apache-hive-2 ...
- varchar2长度的意义
参考:http://www.cnblogs.com/vipcjob/archive/2010/06/08/1754075.html http://www.itpub.net/thread-732714 ...
- 企业SaaS模式的优缺点
好处: 1.降低成本 项目成本.人员成本 2.使用简单 无需系统维护,用户只需登录就可以享受系统的功能 3.安全性 SaaS模式下,企业用户最关注的是自己的数据能不能得到安全保护. A.涉及的数据有哪 ...
- CentOS7 安装Python3,开发SocketIO 客户端
CentOS7安装Python3,开发SocketIO 客户端 参考:https://blog.csdn.net/lovefengruoqing/article/details/79284573 步骤 ...
- ux.form.field.GridDate 支持快速选择日期的日期控件
效果如图,亲测6.2.1版本可用 /** *支持快速选择日期的日期控件 */ Ext.define('ux.form.field.GridDate', { extend: 'Ext.form.fiel ...
- css处理文本溢出
css: .box{ width: 100px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; } white-space: ...
- 18、MySQL
++主键(primary key) 能够唯一标识表中某一行的属性或属性组++.==一个表只能有一个主键==,但可以有多个候选索引.==主键可以保证记录的唯一==和==主键域非空==,数据库管理系统对于 ...
- PostMessage 解析
首先是 windows API 中的一个函数, 作用就是放一条消息到消息队列里. 这个函数讲一个消息放入到与 指定窗口 创建的线程相联系的消息队列里,不等待线程处理消息就返回,是一步消息模式, 消 ...