关于Sencha ExtJS 中 Datefield 控件 load 无法加载数据的问题

Sencha ExtJS 开发中一个比较多的功能就是在编辑某条数据列的时候如果有 datefield 控件时间无法加载入正确的栏目中。

1

而 textfield 控件则能够通过服务器端返回的数据正确加载到相应的控件中,通过官网的论坛给出的答案是:需要修改服务器端返回的时间格式


{
desc: "成功",
totalResult: 9,
items: [
	{
		userId: "null1383919764373",
		userAccount: "yz",
		userIcon: "",
		userMobile: "13888889991",
		userNick: "园长",
		userType: "3",
		regTime: "2013-11-08 22:09:24",
		updateTime: "2013-11-08 22:09:24",
		status: "0",
		point: 0,
		realName: "园长",
		email: "balkc@11.com",
		sex: "0",
		birthday: "2013-11-06 00:00:00",
		orgs: [{
			updateTime: "2013-11-08 22:09:24",
			status: "0"
		}]
	}
	...
Ext.getCmp('base_form').getForm().on({
        actioncomplete: function(form, action) {
            if (action.type === 'load') {
                if (action.result.success) {
                    //绑定开始时间
                    var date = new Date(action.result.data.regTime);
                    var edate = new Date(action.result.data.updateTime);
                    form.setValues({
                        regTime: Ext.Date.format(date,"Y-m-d"),
                        updateTime: Ext.Date.format(edate,"Y-m-d")
                    });
                }
            }
        }
    });

通过使用 Ext.Date.format(框架内置)方法格式化返回的时间格式就能够正常的把时间设置进入控件中。

posted @ 2013-11-15 15:05  可乐加糖  阅读(251)  评论(0编辑  收藏  举报