解决EasyUI的datagrid控件显示日期问题
来源:互联网 发布:linux查看当前进程 编辑:程序博客网 时间:2024/04/29 20:11
在做积分系统的时候,做的是后台管理系统,所以前段框架用的是EasyUI,使用datagrid的时候,后台返回来一个日期格式的数据,当json序列化后返回来的数据就变成了/Date(1419264000000)/
改前代码:
<table id="dg" class="easyui-datagrid" style="width:auto;height:auto" url="/QuestManage/LoadPageQuestIndex" toolbar="#tb" title="题目信息表" singleSelect="false" fitColumns="true" iconCls="icon-save" rownumbers="true" pagination="true" pagesize="10"> <thead> <tr> <th data-options="field:'quesID',hidden:'true'" >题目ID</th> <th data-options="field:'quesContent'"style="width:20%">题目内容</th> <th data-options="field:'quesScore'"style="width:20%">题目分值</th> <th data-options="field:'quesTypeID'"style="width:20%">所属类别</th> <th data-options="field:'quesController'"style="width:20%">所用控件</th> </tr> </thead> </table>
改后代码:
<table id="dg" class="easyui-datagrid" ></table> <script> $('#dg').datagrid({ toolbar:tb, url: '/QuestManage/LoadPage', title: "课程信息", singleSeletct: true, fitColumns: true, rownumbers: true, pagination: true, pagesize: 10, columns: [[ { field: 'quesTypeID', title: '编号', hidden: true }, { field: 'quesType', title: '题型名称', width:40}, { field: 'date', title: '添加时间',width:40, formatter: function (value, row, index) { return changeDateFormat(value) } }, { field: 'operater', title: '操作人', width:25 }, { field: 'userLevel', title: '所属部门', width: 60 } ]] }); //转换日期格式 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(); return date.getFullYear() + "-" + month + "-" + currentDate; } }</script>
效果图:
简单的做一个记录,以后遇到类似的问题,有地方找,这几天有一个很深刻的体会,如果一个问题迟迟没有解决,那就放下半天或者一天,你在解决的时候有很大的几率你会利用很短的时间解决
阅读全文
0 0
- 解决EasyUI的datagrid控件显示日期问题
- 解决easyui无法显示datagrid的问题
- 解决easyUI-datagrid不显示的问题
- 如何解决easyui-datagrid分页组件中文显示的问题
- 如何解决easyui-datagrid分页组件中文显示的问题
- 解决easyui 控件datagrid 二次加载问题
- easyUI的datagrid控件日期列不能正确显示Json格式数据的解决方案
- easyUI的列表控件(datagrid)日期列不能正确显示Json格式数据的解决方法
- easyUI的列表控件(datagrid)日期列不能正确显示的解决方法
- Easyui Datagrid的Rownumber行号显示问题
- Easyui Datagrid的Rownumber行号显示问题
- 解决easyui datagrid 翻页全选的问题
- 解决easyui的datagrid缓存问题
- SpringData JPA easyUI dataGrid数据显示的解决经验
- 第三方控件获取值问题的解决(附转载的easyUI datagrid 时间格式化(两种))
- 自定义EasyUI的datetimebox控件日期时间的显示格式
- EasyUI 解决datagrid 不能自动伸展的问题
- 解决easyUI 1.4.1 dataGrid加载数据慢的问题
- 费用流——BZOJ1877/Luogu2153 [SDOI2009]晨跑
- Excel应用-术语管理模板(记录单新建记录功能的VBA实现)
- Java使用freeMarker生成Word
- JavaScript中正则表达式常见使用函数
- Set 小结
- 解决EasyUI的datagrid控件显示日期问题
- bzoj 4498 魔法的碰撞
- java取整和java四舍五入方法 BigDecimal.setScale()方法详解.
- FFOS cs call
- android binder机制---Java层获取ServiceManager
- 拜小白教你OpenCV3.2.0+VS2017开发环境配置
- 初识Kafka----个人理解,希望对喜欢kafka的朋友有帮助
- 关于Spring的@Profile注解的使用记录
- Deep Learning模型之:CNN卷积神经网络(一)深度解析CNN