extjs 如何取出gridpanel中的日期列
varselModel=grid.getSelectionModel();varrecord=selModel.getSelected();vard=record.dat...
var selModel = grid.getSelectionModel();
var record = selModel.getSelected();
var d = record.data;
alert(d.birthday)
gridpanel里显示的是‘1977-03-02'
而我取出来的是Wed Mar 2 00:00:00 UTC+0800 1977
我现在想要1977-03-02怎么取?请高手指点!
我不晓得平常的一个datefield是否和gridpanel中的有所区别,
record.create中
name : "BIRTHDATE",
type : "string",不是datefield
mapping : "BIRTHDATE"
ColumnModel中
header : "生日",
width : 100,
format : "Y-m-d",
dataIndex : "BIRTHDATE",
renderer : Ext.util.Format.dateRenderer("Y-m-d")
proxy中
ebirthday : Date.parseDate("1977-03-02", "Y-m-d"),
修改按钮中
text : "修改用户",
icon : "../../images/icons/script_edit.png",
cls : "x-btn-text-icon",
handler : function() {
var selModel = grid.getSelectionModel();
var record;
if (!selModel.hasSelection()) {
Ext.Msg.alert("警告", "请选择要修改的行!");
} else if (selModel.getSelections().length > 1) {
Ext.Msg.alert("警告", "只能选择修改一条数据,请重新选择!");
} else {
record = selModel.getSelected();
var d = record.data;
alert(Date.parseDate('Y-m-d',d.BIRTHDATE));
winNew.show();
alert(d.BIRTHDATE.format('Y-m-d'));
Ext.getCmp('birthdate').setValue((d.BIRTHDATE).format('Y-m-d')); 展开
var record = selModel.getSelected();
var d = record.data;
alert(d.birthday)
gridpanel里显示的是‘1977-03-02'
而我取出来的是Wed Mar 2 00:00:00 UTC+0800 1977
我现在想要1977-03-02怎么取?请高手指点!
我不晓得平常的一个datefield是否和gridpanel中的有所区别,
record.create中
name : "BIRTHDATE",
type : "string",不是datefield
mapping : "BIRTHDATE"
ColumnModel中
header : "生日",
width : 100,
format : "Y-m-d",
dataIndex : "BIRTHDATE",
renderer : Ext.util.Format.dateRenderer("Y-m-d")
proxy中
ebirthday : Date.parseDate("1977-03-02", "Y-m-d"),
修改按钮中
text : "修改用户",
icon : "../../images/icons/script_edit.png",
cls : "x-btn-text-icon",
handler : function() {
var selModel = grid.getSelectionModel();
var record;
if (!selModel.hasSelection()) {
Ext.Msg.alert("警告", "请选择要修改的行!");
} else if (selModel.getSelections().length > 1) {
Ext.Msg.alert("警告", "只能选择修改一条数据,请重新选择!");
} else {
record = selModel.getSelected();
var d = record.data;
alert(Date.parseDate('Y-m-d',d.BIRTHDATE));
winNew.show();
alert(d.BIRTHDATE.format('Y-m-d'));
Ext.getCmp('birthdate').setValue((d.BIRTHDATE).format('Y-m-d')); 展开
4个回答
展开全部
用extjs里的Date的format方法..
如xxx.format("Y-m-d");
xxx就是你取出显示Wed Mar 2 00:00:00 UTC+0800 1977的Date对象
详细请查看api文档
写个简单的例子给你:我已运行过.是没问题的
<html>
<head>
<title>dateField.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css"
href="ext-2.3.0/resources/css/ext-all.css" />
<script type="text/javascript"
src="./ext-2.3.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="./ext-2.3.0/ext-all.js"></script>
<script type="text/javascript"
src="./ext-2.3.0/build/locale/ext-lang-zh_CN.js"></script>
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script>
Ext.onReady(function(){
var panel=new Ext.Panel({
width:300,
height:300,
labelWidth:70,
frame:true,
layout:'form',
renderTo:Ext.getBody(),
items:[{xtype:'textfield',fieldLabel:'年龄',width:100},{xtype:'datefield',fieldLabel:'出生年月',width:100,format:'Y-m-d',readOnly:true,value:new Date(),
listeners:{'blur':function(){
var _age=this.getValue();
var age=new Date().getFullYear()-_age.getFullYear();
this.ownerCt.findByType('textfield')[0].setValue(age);
var time=this.getValue();
alert(time);//Tue jul 6:00:00:00 这种格式
alert(time.format("Y-m-d"));//2010-01-09 转换后的格式
}}}
]
});
});
</script>
</head>
<body>
</body>
</html>
如xxx.format("Y-m-d");
xxx就是你取出显示Wed Mar 2 00:00:00 UTC+0800 1977的Date对象
详细请查看api文档
写个简单的例子给你:我已运行过.是没问题的
<html>
<head>
<title>dateField.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css"
href="ext-2.3.0/resources/css/ext-all.css" />
<script type="text/javascript"
src="./ext-2.3.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="./ext-2.3.0/ext-all.js"></script>
<script type="text/javascript"
src="./ext-2.3.0/build/locale/ext-lang-zh_CN.js"></script>
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script>
Ext.onReady(function(){
var panel=new Ext.Panel({
width:300,
height:300,
labelWidth:70,
frame:true,
layout:'form',
renderTo:Ext.getBody(),
items:[{xtype:'textfield',fieldLabel:'年龄',width:100},{xtype:'datefield',fieldLabel:'出生年月',width:100,format:'Y-m-d',readOnly:true,value:new Date(),
listeners:{'blur':function(){
var _age=this.getValue();
var age=new Date().getFullYear()-_age.getFullYear();
this.ownerCt.findByType('textfield')[0].setValue(age);
var time=this.getValue();
alert(time);//Tue jul 6:00:00:00 这种格式
alert(time.format("Y-m-d"));//2010-01-09 转换后的格式
}}}
]
});
});
</script>
</head>
<body>
</body>
</html>
展开全部
用extjs里的Date的format方法..
如xxx.format("Y-m-d");
xxx就是你取出显示Wed Mar 2 00:00:00 UTC+0800 1977的Date对象
详细请查看api文档
写个简单的例子给你:我已运行过.是没问题的
<html>
<head>
<title>dateField.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css"
href="ext-2.3.0/resources/css/ext-all.css" />
<script type="text/javascript"
src="./ext-2.3.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="./ext-2.3.0/ext-all.js"></script>
<script type="text/javascript"
src="./ext-2.3.0/build/locale/ext-lang-zh_CN.js"></script>
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script>
Ext.onReady(function(){
var panel=new Ext.Panel({
width:300,
height:300,
labelWidth:70,
frame:true,
layout:'form',
renderTo:Ext.getBody(),
items:[{xtype:'textfield',fieldLabel:'年龄',width:100},{xtype:'datefield',fieldLabel:'出生年月',width:100,format:'Y-m-d',readOnly:true,value:new Date(),
listeners:{'blur':function(){
var _age=this.getValue();
var age=new Date().getFullYear()-_age.getFullYear();
this.ownerCt.findByType('textfield')[0].setValue(age);
var time=this.getValue();
alert(time);//Tue jul 6:00:00:00 这种格式
alert(time.format("Y-m-d"));//2010-01-09 转换后的格式
}}}
]
});
});
</script>
</head>
<body>
</body>
</html>
如xxx.format("Y-m-d");
xxx就是你取出显示Wed Mar 2 00:00:00 UTC+0800 1977的Date对象
详细请查看api文档
写个简单的例子给你:我已运行过.是没问题的
<html>
<head>
<title>dateField.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css"
href="ext-2.3.0/resources/css/ext-all.css" />
<script type="text/javascript"
src="./ext-2.3.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="./ext-2.3.0/ext-all.js"></script>
<script type="text/javascript"
src="./ext-2.3.0/build/locale/ext-lang-zh_CN.js"></script>
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script>
Ext.onReady(function(){
var panel=new Ext.Panel({
width:300,
height:300,
labelWidth:70,
frame:true,
layout:'form',
renderTo:Ext.getBody(),
items:[{xtype:'textfield',fieldLabel:'年龄',width:100},{xtype:'datefield',fieldLabel:'出生年月',width:100,format:'Y-m-d',readOnly:true,value:new Date(),
listeners:{'blur':function(){
var _age=this.getValue();
var age=new Date().getFullYear()-_age.getFullYear();
this.ownerCt.findByType('textfield')[0].setValue(age);
var time=this.getValue();
alert(time);//Tue jul 6:00:00:00 这种格式
alert(time.format("Y-m-d"));//2010-01-09 转换后的格式
}}}
]
});
});
</script>
</head>
<body>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
renderer: function(value)
{
var reDate = /\d{4}\-\d{2}\-\d{2}/gi;
var reTime = /\d{2}:\d{2}:\d{2}/gi;
return value.match(reDate) + " " + value.match(reTime);
}
{
var reDate = /\d{4}\-\d{2}\-\d{2}/gi;
var reTime = /\d{2}:\d{2}:\d{2}/gi;
return value.match(reDate) + " " + value.match(reTime);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
日期列的editor:new Ext.grid.GridEditor(new Ext.form.DateField({format: 'Y-n-j'})
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询