本节课重点了解 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]的更多相关文章

  1. DataGrid( 数据表格) 组件[9]

    本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...

  2. DataGrid( 数据表格) 组件[8]

    本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...

  3. DataGrid( 数据表格) 组件[7]

    本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...

  4. DataGrid( 数据表格) 组件[6]

    本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...

  5. DataGrid( 数据表格) 组件[4]

    本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...

  6. DataGrid( 数据表格) 组件[3]

    本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...

  7. DataGrid( 数据表格) 组件[2]

    本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...

  8. DataGrid( 数据表格) 组件[1]

    本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...

  9. 第二百二十二节,jQuery EasyUI,DataGrid(数据表格)组件

    jQuery EasyUI,DataGrid(数据表格)组件 学习要点: 1.加载方式 2.分页功能 本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于 Pa ...

随机推荐

  1. mysql UNIX时间戳与日期的相互转换

    UNIX时间戳转换为日期用函数: FROM_UNIXTIME() select FROM_UNIXTIME(1156219870); 日期转换为UNIX时间戳用函数: UNIX_TIMESTAMP() ...

  2. 单点登录CAS使用记(三):实现自定义验证用户登录

    问题: CAS自带的用户验证逻辑太过简单,如何像正常网站一样,通过验证DB中的用户数据,来验证用户以及密码的合法性呢? 方案1:CAS默认的JDBC扩展方案: CAS自带了两种简单的通过JDBC方式验 ...

  3. ios视图切换之push与present混用

    在变成过程中,经常遇到两个视图控制器之间的切换,导航控制器即UINaVigation是最常用的一种,有时为了某些效果又需要进行模态切换,即present. 我们的布局经常是在window上加一个nav ...

  4. ruby on rails 中render的使用

    最近写ror,因为比较菜,很多东西不知道,只能看一点查一点了 render 先上点搜集的常用方式 render :action => "long_goal", :layout ...

  5. smarty练习:考试系统

    考试系统 (0607) 做一个类似于驾校考试的系统,可以选择要考试试题类型,选好后进入考试页面 使用的数据库表格:timu(题目)表,xuanxiang(选项)表,shiti(试题)表,shititi ...

  6. oracle 更改SQL提示

    在oracle里面修改SQL提示为数据库名称: SQL>set SQLPROMPT "TEST>"

  7. Android 获取网络链接类型

    /** * 获取当前网络类型 * @return 0:没有网络 1:WIFI网络 2:WAP网络 3:NET网络 */ public int getNetworkType() { int netTyp ...

  8. Android上传文件之FTP

    android客户端实现FTP文件(包括图片)上传应该没什么难度.写下来就了为了记录一下,望能帮到新手. 需要用到 commons-net-3.0.1.jar,后面附上jar包. 直接上代码: /** ...

  9. C51汇编语言完整源码

    单片机最小系统,两位LED数码管由串口输出接两个164驱动,Lout,Rout为左右声道输出,SET,  ALT0, ALT1为三个按键,也可自己在开始的I/O定义改成你想用的I/O口:12M晶振,若 ...

  10. 设置tableWidget->verticalScrollBar()的属性

    tableWidget->verticalScrollBar()->setStyleSheet("QScrollBar{background:rgb(255,255,0); wi ...