您的位置:首页 > Web前端 > JavaScript

extjs的store默认加载数据时,增加本地一条数据

2012-11-14 09:35 495 查看
extjs的store定义时可以选中手工加载 autoLoad : false,自己在

store.load({
scope: this,
callback: function(records, operation, success) {
this.insert(0,{id:'',name:'本地数据'});
}
});

这个虽然好,但是太过麻烦;更好的解决办法是在定义是添加一个监听

Ext.define(SMS.store.AutoAddData,{

extend: 'Ext.data.Store',



requires:SMS.model.AutoAddData,



model:SMS.model.AutoAddData,



autoLoad : true,



proxy: {

type : 'ajax',

url : '/AutoAddData.action',

reader : {

type
: 'json',

root: ''

}

},



listeners:{

load:{

fn:function(store, records){
this.insert(0,{id:'',name:'本地数据' } );

}

}



});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: