DataGrid( 数据表格) 组件[5]
本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于
Panel(面板)、Resizeable(调整大小)、LinkButton(按钮)、Pageination(分页)组件。
一. 新增功能
columns : [[
{
field : 'user',
title : '帐号',
sortable : true,
width : 100,
editor : {
type : 'validatebox',
options : {
required : true,
},
},
},
{
field : 'email',
title : '邮件',
sortable : true,
width : 100,
editor : {
type : 'validatebox',
options : {
required : true,
validType: 'email',
},
},
},
{
field : 'date',
title : '创建时间',
sortable : true,
width : 100,
editor : {
type : 'datetimebox',
options : {
required : true,
},
},
},
]],
//扩展 dateTimeBox
$.extend($.fn.datagrid.defaults.editors, {
datetimebox : {
init: function(container, options){
var input = $('<input type="text">').appendTo(container);
options.editable = false;
input.datetimebox(options);
return input;
},
getValue: function(target){
return $(target).datetimebox('getValue');
},
setValue: function(target, value){
$(target).datetimebox('setValue', value);
},
resize: function(target, width){
$(target).datetimebox('resize', width);
},
destroy : function (target) {
$(target).datetimebox('destroy');
},
}
});
//实现添加方法
obj = {
editRow : false,
search : function () {
$('#box').datagrid('load', {
user : $.trim($('input[name="user"]').val()),
date_from : $('input[name="date_from"]').val(),
date_to : $('input[name="date_to"]').val(),
});
},
add : function () {
$('#save').show();
$('#redo').show();
if (!this.editRow) {
$('#box').datagrid('endEdit', this.editRow);
} else {
$('#box').datagrid('insertRow', {
index : 0,
row : {
//date : (new Date()).Format("yyyy-MM-dd hh:mm:ss"),
},
});
$('#box').datagrid('beginEdit', 0);
this.editRow = true;
}
},
save : function () {
$('#save,#redo').hide();
this.editRow = false;
//将新增的一行设置为结束编辑状态
$('#box').datagrid('endEdit', 0);
},
redo : function () {
$('#save,#redo').hide();
this.editRow = false;
$('#box').datagrid('rejectChanges');
},
};
onAfterEdit : function (rowIndex, rowData, changes) {
console.log(rowData)
},
L //HTML 部分
<div style="margin-bottom:5px">
<a href="#" class="easyui-linkbutton" iconCls="icon-add"
plain="true" onclick="obj.add();">添加</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-edit"
plain="true">修改</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-remove"
plain="true">删除</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-save"
plain="true" style="display:none;" id="save" onclick="obj.save();">保存
</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-redo"
plain="true" style="display:none;" id="redo" onclick="obj.redo();">取消编
辑</a>
</div>
DataGrid( 数据表格) 组件[5]的更多相关文章
- DataGrid( 数据表格) 组件[9]
本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...
- DataGrid( 数据表格) 组件[8]
本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...
- DataGrid( 数据表格) 组件[7]
本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...
- DataGrid( 数据表格) 组件[6]
本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...
- DataGrid( 数据表格) 组件[4]
本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...
- DataGrid( 数据表格) 组件[3]
本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...
- DataGrid( 数据表格) 组件[2]
本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...
- DataGrid( 数据表格) 组件[1]
本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...
- 第二百二十二节,jQuery EasyUI,DataGrid(数据表格)组件
jQuery EasyUI,DataGrid(数据表格)组件 学习要点: 1.加载方式 2.分页功能 本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于 Pa ...
随机推荐
- js的相关验证
1 var JavaScriptCommon = { /*身份证号码校验*/ VerifyID: function (socialNo) { if (socialNo == "") ...
- Eclipse关闭XML文件验证的方法,解决xml警告
XML的编写是否符合规范,可以通过XML Schema或DTD进行验证,但有时候电脑本来就很卡,而且XML的某些错误并未导致程序无法运行的情况下,暂时关闭XML的验证也算不错的选择. 如web.xml ...
- PowerShell: 如何解决File **.ps1 cannot be loaded because the execution of scripts is disabled on this sy
PowerShell 默认不允许执行*.ps1脚本文件.运行ps1文件会得到下面的错误: File C:\Temp\Test.ps1 cannot be loaded because the exec ...
- php中文匹配
PHP判断字符串中是否含有中文 <? $str = "测试中文"; echo $str; echo "<hr>"; //if (preg_ma ...
- php函数整理
php usleep() 函数延迟代码执行若干微秒. unpack() 函数从二进制字符串对数据进行解包. uniqid() 函数基于以微秒计的当前时间,生成一个唯一的 ID. time_sleep_ ...
- Web之CSS开发技巧: CSS 居中大全
<center> text-align:center 在父容器里水平居中 inline 文字,或 inline 元素 vertical-align:middle 垂直居中 inline 文 ...
- 编程的宗派(OOP与FP孰优孰劣)--王垠
编程的宗派 总是有人喜欢争论这类问题,到底是"函数式编程"(FP)好,还是"面向对象编程"(OOP)好.既然出了两个帮派,就有人积极地做它们的帮众,互相唾骂和鄙 ...
- python常用数据结构的常用操作
作为基础练习吧.列表LIST,元组TUPLE,集合SET,字符串STRING等等,显示,增删,合并... #===========List===================== shoplist ...
- MCS-51单片机的指令时序
时序是用定时单位来描述的,MCS-51的时序单位有四个,它们分别是节拍.状态.机器周期和指令周期,接下来我们分别加以说明. 节拍与状态: 我们把振荡脉冲的周期定义为节拍(为方便描述,用P表示), ...
- 对libssh的golang 封装 ssh2go
ssh2go 是对libssh的go语言绑定.libssh作为ssh的实现库,支持SSHv2和SSHv1的客户.服务端实现,通过libssh你可以远程执行程序.拷贝文件等等. ssh2go不像其他go ...