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

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 17:34   2820   0

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(框架内置)方法格式化返回的时间格式就能够正常的把时间设置进入控件中。

转载于:https://www.cnblogs.com/blackagenl/p/4316773.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP