Extjs怎么格式化Grid的日期列
2012-09-13 11:19
162 查看
在Grid的cm里面定义列的时候使用renderer 属性进行修改日期格式.由于在用.net把List<T>转成json的时候会把日期类型转化成不是常用的格式所以我们需要利用js把他转换过来.
第一步需要把他转换成js认识的Date格式:new Date(parseInt(val.substring(6, val.length - 2)))
第二步再把Date按照你的要求进行转化,我这里是扩展了一个format方法
下面是具体Grid日期列的定义
第一步需要把他转换成js认识的Date格式:new Date(parseInt(val.substring(6, val.length - 2)))
第二步再把Date按照你的要求进行转化,我这里是扩展了一个format方法
Date.prototype.format = function(format) { var o = { "M+": this.getMonth() + 1, //month "d+": this.getDate(), //day "h+": this.getHours(), //hour "m+": this.getMinutes(), //minute "s+": this.getSeconds(), //second "q+": Math.floor((this.getMonth() + 3) / 3), //quarter "S": this.getMilliseconds() //millisecond } if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); return format; }
下面是具体Grid日期列的定义
{dataIndex : 'BillDate', header : '用电日期', hidden : false, renderer : function (val) { return new Date(parseInt(val.substring(6, val.length - 2))).format('yyyy-MM-dd') } , sortable : false }
相关文章推荐
- Extjs怎么格式化Grid的日期列
- extjs单元格点击事件,extjs grid中一行或者一个单元格中有多个链接的时候怎么判断是哪一个?
- ExtJs中grid数据格式化
- 格式化grid日期
- extjs4.2 grid 日期在ie中出现0NaN-NaN-NaN
- 面试题1 -- Java 中,怎么在格式化的日期中显示时区?
- ExtJs ExtenderControl 日期格式化处理
- Extjs日期/可编辑表格grid/显示不正确————解决方案
- Extjs里表格grid显示日期类型数据
- Kendo UI:Grid中单元格日期格式化
- Extjs4.x转换后台传过来的JSON日期为标准的日期对象_+数字格式化
- Ext.Net 中的GridPanle列中日期进行格式化
- extjs显示格式化返回JSON格式的日期
- Extjs里表格grid显示日期类型数据
- Extjs怎么删除Grid的记录
- extjs 日期格式化参数对应关系
- json时间格式(时间戳)转成Extjs日期格式(grid字段的时间)
- Ext gridPanel 日期格式化
- 怎么格式化业务表单域中的日期显示方式
- Extjs怎么给Grid增加一个CheckBox列