博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
EasyUI表格columns单元格正确显示时间格式
阅读量:7007 次
发布时间:2019-06-27

本文共 3647 字,大约阅读时间需要 12 分钟。

下面红色部分正是关键:

 这些都是同一个JS页面的代码:

//初始化表格function initTable() {    $('#test').datagrid({        title: '学生作业列表',        iconCls: 'icon-user',        loadMsg: '数据加载中...',        nowrap: true,        autoRowHeight: true,        striped: true,        url: '/CorrectHomeWork/GetAllHomeWork',        sortName: 'ID',        sortOrder: 'asc',        border: true,        remoteSort: false,        idField: 'ID',        pageSize: 10,        pagination: true,        rownumbers: true,        columns: [[            { field: 'ck', checkbox: true },            { field: 'ID', title: 'ID', width: 50, sortable: true },            { field: 'S_Number', title: '学号', width: 100, sortable: true },            { field: 'HW_Url', title: "作业名", width: 150, sortable: true },            {                field: 'HW_SubmitDate', title: '初次提交时间', width: 150,                formatter: function (value, row, index) {                    return changeDateFormat(value);                }            },            {                field: 'HW_UpdataDate', title: '再次提交时间', width: 150,                formatter: function (value, row, index) {                    return changeDateFormat(value);                }            },                        {                field: 'RegistrationTime', title: "注册时间", width: 150, sortable: true,                formatter: function (value, row, index) {                    //return (eval(value.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"))).pattern("yyyy-M-d h:m:s");                }            },            { field: 'UserRoleId', title: "权限", width: 150, sortable: true },            {                field: 'Enable', title: '是否启用', width: 80, formatter: function (val, rowdata, index) {                    if (val) {                        return '' + val + '';                    } else {                        return '' + val + '';                    }                }            }        ]],        onLoadSuccess: function () {            $(".grid_Enable").linkbutton({ text: '启用', plain: true, iconCls: 'icon-ok' });            $(".grid_unEnable").linkbutton({ text: '禁止', plain: true, iconCls: 'icon-no' });        },        toolbar: [{            id: 'btnadd',            text: '添加用户',            iconCls: 'icon-add',            handler: function () {                AddUserDialog();            }        }, '-', {            id: 'btnedit',            text: '修改用户',            iconCls: 'icon-edit',            handler: function () {                UpdateUserDialog();            }        }, '-', {            id: 'btncut',            text: '删除用户',            iconCls: 'icon-cut',            handler: function () {                DeleteUser();            }        }, '-', {            id: 'btnrefresh',            text: '刷新',            iconCls: 'icon-reload',            handler: function () {                initTable();            }        }]    });}

 

//转换日期格式 

function changeDateFormat(cellval) {
if (cellval != null) {
var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var currentHours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
var currentMinutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
var currentSeconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
return date.getFullYear() + "-" + month + "-" + currentDate + " "+" " + currentHours + ":" + currentMinutes + ":" + currentSeconds;
}
}

  

转载于:https://www.cnblogs.com/fzqm-lwz/p/10669253.html

你可能感兴趣的文章
ArcGIS Engine开发之旅01---产品组成、逻辑体系结构
查看>>
xen虚拟化实战系列(一)之xen虚拟化环境安装
查看>>
龙骑排雷技巧
查看>>
绑定裸设备(查看裸设备的大小)
查看>>
防止一个用户登录多次的方法
查看>>
zookeeper部署及集群测试
查看>>
基于开源 Openfire 聊天服务器 - 开发Openfire聊天记录插件
查看>>
webservice 测试窗体只能用于来自本地计算机的请求
查看>>
WinForm 窗体间传递数据的一些方法[转]
查看>>
在VS2010上使用C#调用非托管C++生成的DLL文件(图文讲解) 背景
查看>>
如何搭建ipv6网络
查看>>
html 常用的标签
查看>>
jquery之on()绑定事件和off()解除绑定事件
查看>>
“ji32k7au4a83”被用作密码的次数不太正常
查看>>
DAX函数大全
查看>>
【剧透】2017云栖大会·北京峰会——企业云上业务优化专场
查看>>
突然想起的几个小故事
查看>>
《R语言编程艺术》——1.6 启动和关闭R
查看>>
云计算成绩出色 迅雷营收再获重要支撑
查看>>
微软说它深爱着Linux,现在它用行动证明了
查看>>