1、在easyui datagrid 中序列化后的日期显示为:/Date(1433377800000)/

2、格式化后的显示为: 2015-06-04 08:30:00

3、使用代码如下:

3.1、

  1. $('#dg').datagrid({
  2. url: 'index',
  3. method: 'post',
  4. title: '操作元素管理',
  5. iconCls: 'icon-save',
  6. dataType: "json",
  7. rownumbers: true, //是否加行号
  8. pagination: true, //是否显式分页
  9. pageSize: 15, //页容量,必须和pageList对应起来,否则会报错
  10. pageNumber: 2, //默认显示第几页
  11. pageList: [15, 30, 45],//分页中下拉选项的数值
  12. width: 1000,
  13. height: 500,
  14. fitColumns: true,
  15. singleSelect: false,
  16. columns: [[
  17. { field: "chk", checkbox: true },
  18. { field: 'Id', title: 'Id', width: 70 },
  19. { field: 'ButtonText', title: 'ButtonText', width: 120, editor: { type: 'text' } },
  20. { field: 'IconCls', title: 'IconCls', width: 120, editor: { type: 'text' } },
  21. { field: 'IconUrl', title: 'IconUrl', width: 120, editor: { type: 'text' } },
  22. { field: 'ButtonTag', title: 'ButtonTag', width: 120, editor: { type: 'text' } },
  23. { field: 'ButtonHtml', title: 'ButtonHtml', width: 120, editor: { type: 'text' } },
  24. { field: 'Remark', title: 'Remark', width: 120, editor: { type: 'text' } },
  25. {
  26. field: 'AddTime', title: 'AddTime', width: 120, formatter: function (value, row, index) {
  27. var date = value.substr(1, value.length - 2);
  28. date = value.substr(1, value.length - 2);
  29. date = eval('(new ' + date + ');');
  30. return date.format("yyyy-MM-dd HH:mm:ss");
  31. }
  32. },
  33. { field: 'SortNum', title: 'SortNum', width: 120, editor: { type: 'numberbox' } },
  34.  
  35. ]]
  36.  
  37. });

  js格式化函数

  1. /*
  2. 函数:格式化日期
  3. 参数:formatStr-格式化字符串
  4. d:将日显示为不带前导零的数字,如1
  5. dd:将日显示为带前导零的数字,如01
  6. ddd:将日显示为缩写形式,如Sun
  7. dddd:将日显示为全名,如Sunday
  8. M:将月份显示为不带前导零的数字,如一月显示为1
  9. MM:将月份显示为带前导零的数字,如01
  10. MMM:将月份显示为缩写形式,如Jan
  11. MMMM:将月份显示为完整月份名,如January
  12. yy:以两位数字格式显示年份
  13. yyyy:以四位数字格式显示年份
  14. h:使用12小时制将小时显示为不带前导零的数字,注意||的用法
  15. hh:使用12小时制将小时显示为带前导零的数字
  16. H:使用24小时制将小时显示为不带前导零的数字
  17. HH:使用24小时制将小时显示为带前导零的数字
  18. m:将分钟显示为不带前导零的数字
  19. mm:将分钟显示为带前导零的数字
  20. s:将秒显示为不带前导零的数字
  21. ss:将秒显示为带前导零的数字
  22. l:将毫秒显示为不带前导零的数字
  23. ll:将毫秒显示为带前导零的数字
  24. tt:显示am/pm
  25. TT:显示AM/PM
  26. 返回:格式化后的日期
  27. */
  28. Date.prototype.format = function (formatStr) {
  29. var date = this;
  30. /*
  31. 函数:填充0字符
  32. 参数:value-需要填充的字符串, length-总长度
  33. 返回:填充后的字符串
  34. */
  35. var zeroize = function (value, length) {
  36. if (!length) {
  37. length = 2;
  38. }
  39. value = new String(value);
  40. for (var i = 0, zeros = ''; i < (length - value.length) ; i++) {
  41. zeros += '0';
  42. }
  43. return zeros + value;
  44. };
  45. return formatStr.replace(/d{1,4}|M{1,4}|yy(?:yy)?|[hH]{1,2}|m{1,2}|s{1,2}|l{1,2}\b/g, function ($0) {
  46. switch ($0) {
  47. case 'd': return date.getDate();
  48. case 'dd': return zeroize(date.getDate());
  49. //case 'ddd': return ['Sun', 'Mon', 'Tue', 'Wed', 'Thr', 'Fri', 'Sat'][date.getDay()];
  50. //case 'dddd': return ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][date.getDay()];
  51. case 'M': return date.getMonth() + 1;
  52. case 'MM': return zeroize(date.getMonth() + 1);
  53. //case 'MMM': return ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][date.getMonth()];
  54. //case 'MMMM': return ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][date.getMonth()];
  55. case 'yy': return new String(date.getFullYear()).substr(2);
  56. case 'yyyy': return date.getFullYear();
  57. case 'h': return date.getHours() % 12 || 12;
  58. case 'hh': return zeroize(date.getHours() % 12 || 12);
  59. case 'H': return date.getHours();
  60. case 'HH': return zeroize(date.getHours());
  61. case 'm': return date.getMinutes();
  62. case 'mm': return zeroize(date.getMinutes());
  63. case 's': return date.getSeconds();
  64. case 'ss': return zeroize(date.getSeconds());
  65. case 'l': return date.getMilliseconds();
  66. case 'll': return zeroize(date.getMilliseconds(), 3);
  67. //case 'tt': return date.getHours() < 12 ? 'am' : 'pm';
  68. //case 'TT': return date.getHours() < 12 ? 'AM' : 'PM';
  69. }
  70. });
  71. }

  

easyui datagrid 中序列化后的日期格式化的更多相关文章

  1. JQuery easyUi datagrid 中 自定义editor作为列表操作按钮列

    转自   http://blog.csdn.net/tianlincao/article/details/7494467 前言 JQuery easyUi datagrid 中 使用datagrid生 ...

  2. easyui datagrid中 多表头方法总结

    easyui datagrid中怎么设置表头成多行显示呢?其实很简单,就是给datagrid的columns属性设置成多个数组就行了.下面直接看例子吧,这是一个两行表头的,按照此方法,还可以设置三行表 ...

  3. EasyUI DataGrid 中字段 formatter 格式化不起作用

    今天用 EasyUI datagrid 来做列表,要对一些数据进行格式化,推断某字段状态时,发现 formatter 格式化相应的函数不起作用. <table id="list_dat ...

  4. EasyUi DataGrid中数据编辑方式及编辑后数据获取,校验处理

    EasyUi中的DataGrid提供前台编辑的相关函数. 实现客户选中DataGrid中一列后,对选中列中的一个字段进行编辑,并对数据进行实时校验后,传递至后台保存的需求, 主要涉及到DataGrid ...

  5. easyui datagrid中datetime字段的显示和增删改查问题

    datagrid中datetime字段的异常显示: 使用过easyui datagrid的应该都知道,如果数据库中的字段是datetime类型,绑定在datagrid显式的时候会不正常显示,一般需要借 ...

  6. JQuery easyUi datagrid 中 editor 动态设置最大值最小值

    前言 近来项目中使用到 easyui 来进行页面设计,感觉挺方便的,但是网上除了api外,其他有价值的资料比较少,故在此分享一点经验,供大家参考.   问题 JQuery easyUi datagri ...

  7. jquery easyui datagrid翻页后再查询始终从第一页开始

    在查询之前将datagrid的属性pageNumber重新设置为1 var opts = grid.datagrid('options'); opts.pageNumber = 1; easyui d ...

  8. easyui datagrid中关联combox

    datagrid中列上关联combobox{ field: 'SysCode', title: '系统代码', width: 150, align: 'left', editor: { type: ' ...

  9. 在easyui datagrid中formatter数据后使用linkbutton

    http://ntzrj513.blog.163.com/blog/static/2794561220139245411997/ formatter:function(value,rowData,ro ...

随机推荐

  1. 第二次作业之——AchaoCalculator

    AchaoCalculator(阿超计算器) GIT地址 我的GitHub GIT用户名 Pastrain 学号后五位 62213 博客地址 我的博客地址 作业链接 作业内容 Part.1 配置VS中 ...

  2. nano的简单笔记

    CTRL+c 显示行数信息 ctrl + _ 到某行 alt +m 移动光标功能 alt+y 语法矫正功能

  3. 2019安徽省程序设计竞赛 D.自驾游(最短路)

    这道题最后没过,估计是痛失省一了,现在来补一下,当时思路是对的应该是代码出了问题导致样例没过最后nc的除了2,一直WA 题意: 给一张联通图,有两个导航系统,其中一个系统认为第i条边的权值是Pi,另一 ...

  4. sql中如何获取一条数据中所有字段的名称和值

    declare ) ) --获取表的列名 ,),filename INTO #templist FROM (select cl.name as filename from sys.tables AS ...

  5. 微信小程序——选择某个区间的数字

    很久没有更新文章啦~~记录下今天弄的一个小功能. 先上图: 需求很简单: 第1列改变的时候,第2列也随着改变,并且比第1列大1k. 这里用到了微信的picker 组件,对于不太熟练这个组件的小伙伴可以 ...

  6. 决策树——C4.5

    -- coding: utf-8 -- """ Created on Thu Aug 2 17:09:34 2018 决策树ID3,C4.5的实现 @author: we ...

  7. maven install

    1. install maven under ubuntu apt install maven 2 speed up package download vim ~/.m2/settings.xml & ...

  8. shell test条件检查

    Shell test 命令 Shell中的 test 命令用于检查某个条件是否成立,它可以进行数值.字符和文件三个方面的测试. 数值测试 参数 说明 -eq 等于则为真 -ne 不等于则为真 -gt ...

  9. P2340 奶牛会展 DP 背包

    P2340 奶牛会展 DP \(n\)头牛,每头牛有智商\(s[i]\)情商\(f[i]\),问如何从中选择几头牛使得智商情商之和最大 且 情商之和.智商之和非负 \(n\le 400,-10^3\l ...

  10. P1913 L国的战斗之伞兵

    题目链接 P1913 L国的战斗之伞兵 思路 从无风点倒着dfs,本来是道大水题,结果输入的时候第二层循环打错了!手残打成i++ 代码 #include<iostream> #includ ...