Extjs

Extjs form加载数据两种方法

2016-05-19  本文已影响800人  Nexthy
loadRecord()

code:

Ext.define("UserModel", {
    extend: 'Ext.data.Model',
    fields: ["userId", "userName"]
});

var userRecord = Ext.create("UserModel", {
    userId: "1",
    userName: "youring"
});

var formCmp = this.up("form");
formCmp.loadRecord(userRecord);

loadData()

code:

Ext.define("Ext.overrides.form.Panel", {
    override: "Ext.form.Panel",
    loadData : function(data){    
        if(data){        
            for(var key in data){            
                var field = this.down('[name='+ key + ']');            
                if(field){                
                    field.setValue(data[key]);            
                }        
            }    
        }
    }
});
上一篇下一篇

猜你喜欢

热点阅读