显示效果:
日期:2016-01-01
时间:2016-01-01 11:11
标题:标题名称...
页面:
<table id="tbList" style="height: 340px;" striped="true" rownumbers="true" iconcls="icon-edit" nowrap="false" idfield="Id" url="@Url.Action("ListData")"> <tr> <th field="Date" formatter="Common.DateFormatter" width="80"> 日期 </th> <th field="Date" formatter="Common.TitleFormatter" width="100"> 标题 </th> </tr> </table>
JS:
var Common = { //EasyUI用DataGrid用日期格式化 TimeFormatter: function (value, rec, index) { if (value == undefined) { return ""; } /*json格式时间转js时间格式*/ value = value.substr(1, value.length - 2); var obj = eval('(' + "{Date: new " + value + "}" + ')'); var dateValue = obj["Date"]; if (dateValue.getFullYear() < 1900) { return ""; } var val = dateValue.format("yyyy-mm-dd HH:MM"); return val.substr(11, 5); }, DateTimeFormatter: function (value, rec, index) { if (value == undefined) { return ""; } /*json格式时间转js时间格式*/ value = value.substr(1, value.length - 2); var obj = eval('(' + "{Date: new " + value + "}" + ')'); var dateValue = obj["Date"]; if (dateValue.getFullYear() < 1900) { return ""; } return dateValue.format("yyyy-mm-dd HH:MM"); }, //EasyUI用DataGrid用日期格式化 DateFormatter: function (value, rec, index) { if (value == undefined) { return ""; } /*json格式时间转js时间格式*/ value = value.substr(1, value.length - 2); var obj = eval('(' + "{Date: new " + value + "}" + ')'); var dateValue = obj["Date"]; if (dateValue.getFullYear() < 1900) { return ""; } return dateValue.format("yyyy-mm-dd"); }, TitleFormatter : function (value, rec, index) { if (value.length > 10) value = value.substr(0, 8) + "..."; return value; }, LongTitleFormatter: function (value, rec, index) { if (value.length > 15) value = value.substr(0, 12) + "..."; return value; } };
时间: 2024-09-30 09:35:22