JQuery EasyUI学习记录(五)
1.datagrid使用方法(重要)
1.1将静态html渲染为datagrid样式
<!--方式一: 将静态html渲染为datagrid样式 -->
<table class="easyui-datagrid">
<thead>
<tr>
<th data-options="field:'id'">编号</th>
<th data-options="field:'name'">姓名</th>
<th data-options="field:'age'">年龄</th>
</tr>
</thead>
<tbody>
<tr>
<td>001</td>
<td>小明</td>
<td>20</td>
</tr>
<tr>
<td>002</td>
<td>小王</td>
<td>21</td>
</tr>
</tbody>
</table>
1.2发送ajax请求获取json数据创建datagrid
<table data-options="url:'${pageContext.request.contextPath}/json/datagrid-data.json'" class="easyui-datagrid">
<thead>
<tr>
<th data-options="field:'id'">编号</th>
<th data-options="field:'name'">姓名</th>
<th data-options="field:'age'">年龄</th>
</tr>
</thead>
</table>
json文件:
{"id":"001", "name":"小明" , "age":15 },
{"id":"002", "name":"小红" , "age":15 },
{"id":"003", "name":"小黄" , "age":15 }
1.3使用easyUI提供的API创建datagrid
<table id="myTable"></table>
<script type="text/javascript">
$(function(){
//页面加载完成后,创建数据表格datagrid
$("#myTable").datagrid({
//定义标题行所偶遇的列,即头行
columns:[[
{title:'编号',field:'id',checkbox:true},
{title:'姓名',field:'name'},
{title:'年龄',field:'age'},
{title:'地址',field:'address'}
]],
//指定数据表格发送ajax请求
url:'${pageContext.request.contextPath}/json/datagrid-data.json',
//行号
rownumbers:true,
//是否单选
singleSelect:true,
//定义工具栏
toolbar:[
{text:'添加',iconCls:'icon-add',
//为按钮绑定事件
handler:function(){
alert(1);
}
},
{text:'删除',iconCls:'icon-remove'},
{text:'修改',iconCls:'icon-edit'},
{text:'查询',iconCls:'icon-search'}
],
//显示分页栏,仅前台展示
pagination:true
});
})
</script>
1.4数据表格datagrid提供的方法,用于获取所有选中的行:getSelections
<table id="grid"></table>
// 取派员信息表格
$('#grid').datagrid( {
iconCls : 'icon-forward',
//自适应
fit : true,
border : false,
rownumbers : true,
striped : true,
//每页显示的页数
pageList: [30,50,100],
pagination : true,
toolbar : toolbar,
url : "staffAction_pageQuery.action",
idField : 'id',
columns : columns,
//绑定双击事件
onDblClickRow : doDblClickRow
});
// 定义列
var columns = [ [ {
field : 'id',
checkbox : true,
},{
field : 'name',
title : '姓名',
width : 120,
align : 'center'
}, {
field : 'telephone',
title : '手机号',
width : 120,
align : 'center'
}, {
field : 'haspda',
title : '是否有PDA',
width : 120,
align : 'center',
formatter : function(data,row, index){
if(data=="1"){
return "有";
}else{
return "无";
}
}
}, {
field : 'deltag',
title : '是否作废',
width : 120,
align : 'center',
formatter : function(data,row, index){
if(data=="0"){
return "正常使用"
}else{
return "已作废";
}
}
}, {
field : 'standard',
title : '取派标准',
width : 120,
align : 'center'
}, {
field : 'station',
title : '所谓单位',
width : 200,
align : 'center'
} ] ];
修改删除按钮绑定的事件:
function doDelete(){
//获取数据表格中所有选中的行,返回数组对象
var rows = $("#grid").datagrid("getSelections");
if(rows.length == 0){
//没有选中记录,弹出提示
$.messager.alert("提示信息","请选择需要删除的取派员!","warning");
}else{
//选中了取派员,弹出确认框
$.messager.confirm("删除确认","你确定要删除选中的取派员吗?",function(r){
if(r){ var array = new Array();
//确定,发送请求
//获取所有选中的取派员的id
for(var i=0;i<rows.length;i++){
var staff = rows[i];//json对象
var id = staff.id;
array.push(id);
}
var ids = array.join(",");//1,2,3,4,5
location.href = "staffAction_deleteBatch.action?ids="+ids;
}
});
}
}
1.1 使用easyUI提供的API创建datagrid(掌握)
JQuery EasyUI学习记录(五)的更多相关文章
- JQuery EasyUI学习记录(三)
1.jQuery EasyUI messager使用方式 1.1 alert方法 $(function(){ //1.alert方法---提示框 $.messager.alert("标题&q ...
- JQuery EasyUI学习记录(二)
1.jquery easyUI动态添加选项卡(查看jquery easyUI手册) 1.1 用于动态添加一个选项卡 1.1.1 选中指定的选项卡和判断某个选项卡是否存在 测试代码: <a id= ...
- JQuery EasyUI学习记录(一)
1.主页设计(JQuery EasyUI插件) 下载easyUI开发包: 将easyUI资源文件导入页面中: <link rel="stylesheet" type=&quo ...
- JQuery EasyUI学习记录(四)
1.EasyUI中的validatebox使用 提供的校验规则: 1.非空校验required="required" 2.使用validType指定 email: 正则表达式匹配电 ...
- jQuery EasyUI学习资源汇总
jQuery EasyUI学习资源汇总 EasyUi – 1.入门 EasyUi – 2.布局Layout + 3.登录界面 EasyUi – 4.datwagrid 学习Jquery EasyUI的 ...
- JQuery EasyUI学习框架
前言 前端技术,新项目的开发拟使用EasyUI框架(基于EasyUI丰富UI组件库),项目负责人的提示EasyUI分配给我这个任务.发展前,我需要这对于一个新手EasyUI框架学习一些基本的入门.记录 ...
- JQuery EasyUI学习笔记
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6690888.html 简介与准备 jQuery EasyUI 是一个基于 jQuery 的框架,集成了各种用 ...
- jQuery EasyUI学习二
1. 课程介绍 1. Datagrid组件(掌握) 2. Dialog.form组件(掌握) 3. Layout.Tabs;(掌握) Datagrid组件 2.1. 部署运行pss启动无错 ...
- EasyUI学习总结(五)——EasyUI组件使用
一.EasyUI组件的简单介绍 easyUI提供了很多组件让我们使用,如下图所示:
随机推荐
- 洛谷P1137 旅行计划
P1137 旅行计划 题目描述 小明要去一个国家旅游.这个国家有N个城市,编号为1-N,并且有M条道路连接着,小明准备从其中一个城市出发,并只往东走到城市i停止. 所以他就需要选择最先到达的城市,并制 ...
- [Xcode 实际操作]五、使用表格-(10)插入UITableView单元格
目录:[Swift]Xcode实际操作 本文将演示如何插入一行单元格. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit //首先添加两个协 ...
- Node.js 内置模块crypto加密模块(1) MD5 和 SHA
MD5:消息摘要算法(Message-Digest Algorithm) SHA家族:安全散列算法( Secure Hash Algorithm ) 1.首先看一个简单的加密 "use st ...
- python接口测试框架遇到的坑(一)excel数字转文本
一.遇到的问题 python编写接口测试框架中,接口用例使用excel维护,其中预期值(code码的值)20000和实际值总是不一致,后来通过打印type发现一个是unicode,一个是float. ...
- iOS - 验证输入的是否是正确的身份证号码和手机号码
- (BOOL)checkIdentityCardNo:(NSString*)cardNo { if (cardNo.length != 18) { return NO; } NSArray* co ...
- LeetCode 刷题笔记 (树)
1. minimum-depth-of-binary-tree 题目描述 Given a binary tree, find its minimum depth.The minimum depth ...
- Python-12-简单推导
列表推导:从其他列表创建列表 >>> [x * x for x in range(10)] [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] 下面实现只打印能 ...
- 如何使用JMeter从文件中提取数据
在性能测试方面,重用响应数据至关重要.几乎(如果不是全部!)负载测试场景假设您: 从先前的响应中提取有趣的方面,并在下一个请求中重用它们(也称为相关) 确保实际响应符合预期(又称断言) 因此,如果您是 ...
- Eclipse Photon 小技巧(tips)
本文内容: Eclipse 4.8版本 代号 photon 光量子 ,感觉更像ide了,虽然这些技巧广为认知,但是作为eclipse来说,也是很重要的. Code completion allows ...
- js json与字符串相互转换
JSON.parse(jsonstr); //可以将json字符串转换成json对象 JSON.stringify(jsonobj); //可以将json对象转换成json对符串