Hi,
I am in a migration of an app from ExtJS 3 to 6... I know, hell. But now I'm stucked in a problem transferring function which is a reading from a JSON data source.
The old app works as:
- a json store created with an url to the json data source
- the data source provides more data than I need
- the json store has the fields config value, which limits what fields are in the resulted record
It worked as it described above. I see the fields parameter still exists in extjs 6, i use it, but the record i get after the store loads, contains all the unnecessary fields. It is wrong for me beause i populate a form using that record and it overwrites fields that i don't want.
An example:
JSON:
Code:
{data:[{field1:val1,field2:val2,field3:val3,field4:val4}]}
The old code, where rec has only field1 and field2:
Code:
var store = new Ext.data.JsonStore({
url: 'datasource.php',
root: "data",
autoLoad: true,
fields: ['field1', 'field2'],
listeners: {
load: function(ds, rec){
console.log(rec);
}
}
});
The new ExtJS 6 code where unfortunetly rec has field1, field2, field3, field4:
Code:
var store = new Ext.data.JsonStore({
proxy: {
type: 'ajax',
method: 'POST',
url: 'datasource.php',
reader: {
rootProperty: "data",
type: 'json'
}
},
fields: ['field1', 'field2'],
autoLoad: true,
listeners: {
load: function(ds, rec){
console.log(rec);
}
}
});
Can anybody help me solve this problem? Thanks.