默认显示的日期列值是含时间的日期类型,于是想改成只显示年-月-日格式的日期,EasyUI支持datagrid的列格式化,需要再datagrid的列中指定formatter的函数来实现对列的内容的格式化显示
代码如下:
<script>
function formatterdate(val, row) {
var date = new Date(val);
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
}
</script>
<table id="track-grid" style="width:680px;height:420px;" toolbar="#tlb_track"
rownumbers="true" fitColumns="true" singleSelect="true" idField="Identifier">
<thead>
<tr>
<th field="Identifier" hidden="true" width="0" >Id</th>
<th field="Create_Date" width="100" editor="{type:'validatebox',required:true}" formatter="formatterdate">发布时间</th>
<th field="Tracker" width="100" editor="{type:'validatebox',required:true}">用户</th>
<th field="Track_Content" width="200" editor="{type:'validatebox',required:true}">内容</th>
</tr>
</thead>
</table>
Mikel