zoukankan      html  css  js  c++  java
  • 使用easyui框架 设置时间格式

    之前做的一个商城项目,后台系统页面使用Easyui做的,记录一个当时卡住的地方:

    首先通过<table>标记创建数据网格(datagrid)

    <table class="easyui-datagrid" id="contentList" data-options="toolbar:contentListToolbar,singleSelect:false,collapsible:true,pagination:true,method:'get',pageSize:20,url:'*******',queryParams:{categoryId:0}">
        <thead>
        <tr>
       <th data-options="field:'id',30">ID</th>
       <th data-options="field:'title',120">内容标题</th>
       <th data-options="field:'subTitle',100">内容子标题</th>
       <th data-options="field:'pic',50,align:'center'">图片</th>
       <th data-options="field:'created',130,align:'center'">创建日期</th>
       <th data-options="field:'updated',130,align:'center'">更新日期</th>
    </tr>
    </thead>
    </table>

    接着在js写一个方法并引用

    formatDateTime : function(val,row){

    var now = new Date(val);
     return now.format("yyyy-MM-dd hh:mm:ss");

    }

    最后在需要更改那一栏添加改方法

    <th data-options="field:'created',130,align:'center',formatter:E3.formatDateTime">创建日期</th>

    <th data-options="field:'updated',130,align:'center',formatter:E3.formatDateTime">更新日期</th>

    效果如下:

    End——————————————————————

  • 相关阅读:
    周总结07(2018.1.8-2018.1.13)
    软件工程概论课总结
    第二阶段团队冲刺-seven
    人月神话阅读笔记06
    第二阶段团队冲刺-six
    周总结06(2018.1.1-2018.1.6)
    第二阶段团队冲刺-five
    开发记录06
    开发记录05
    开发记录04
  • 原文地址:https://www.cnblogs.com/wangxiaomo/p/11589883.html
Copyright © 2011-2022 走看看