问题描述
我正在使用extjs sencha存储来存储数据。我对Web服务进行代理调用以获取数据。我使用store.load()函数刷新数据。我正在寻找在给予网格之前收到的数据。
我知道加载事件,但是这个函数在加载完成后被执行,数据被填充当前数据。
听众:{
'load':function(store,records,options){
}
},
我正在寻找在分配给商店之前如何从Web服务编辑返回的数据。基本上从我的webservice返回的数据格式与我们给extjs datagrid的格式不同。所以,在我们给网格之前,要做一个数据操作。希望我们可以做到这一点。
Thx
模型映射可以帮你做这个还有一个可以提供的转换功能。以下是文档:
Ext.define('User',{
extends:'Ext.data.Model',
字段:[
{
名称:'firstName',
convert:function(value,record){
var fullName = record.get('name'
splitits = fullName.split(),
firstName = splitits [0];
return firstName;
}
},
'name','email',
{name:'age',type:'int'},
{name:'gender',type:'string',defaultValue:'Unknown'}
]
});
I am using extjs sencha store for storing data. I make a proxy call to a web-service to get data. I refresh the data using store.load() function.
I am looking to edit the data that is received before it is given to the grid.
I know about the load event, but this function is executed after the load is completed and data is populated with the current data.
listeners : {
'load' : function(store,records, options) {
}
},
I am looking to see how I can edit the returned data from web-service before it is assigned to the store. Basically data returned from my webservice is in different format than the format we give to extjs datagrid. So, want to do a data operation before we give to the grid. Hope we can do this.
Thx
Model mappings can help you do this. There is a conversion function that can be supplied as well. Here is the example from the docs:
Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{
name: 'firstName',
convert: function(value, record) {
var fullName = record.get('name'),
splits = fullName.split(" "),
firstName = splits[0];
return firstName;
}
},
'name', 'email',
{name: 'age', type: 'int'},
{name: 'gender', type: 'string', defaultValue: 'Unknown'}
]
});
这篇关于数据接收后,进程extjs存储代理数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!