Hi guys,
I'm using Ext.Ajax.request to get my data.
Everything goes well, I get all the data I need in my success method.
The problem starts when I fill my TreeStore with the received data, using .setProxy() method of the store.
My model seems to be ok. However, when I fill the store, I noticed that an extra field, named "tag" is generated.
So my assumption is that at a certain point, when that field gets inserted in my store, the Model skips the remaining fields, which leaves them empty.
Anyway, here the code:
Code:
Ext.Ajax.request({
url:*url*,
params:{
mijnData:loginGegevens
},
method:'POST',
success:function (result, request) {
var jsonData = Ext.decode(result.responseText);
if (jsonData){
console.log("Succes", result);
console.log(jsonData);
if(result.responseText === '{"items":[]}'){
alert("Naam en/of uw wachtwoord was incorrect.");
}
else
{
MijnMvc.stores.aanpassenStore.setProxy({
type:'memory',
data: jsonData,
reader: {
type: 'tree',
root: 'items'
}
});
MijnMvc.stores.aanpassenStore.load();
Ext.dispatch({
controller: 'MijnController',
action: 'startBuildPages'
});
}
} else {
alert("Er is iets fout gelopen naar de database");
}
},
failure:function (result, request) {
console.log('Failed', result.responseText);
},
reader: {
type: 'tree',
root: 'items'
}
});
My model:
Code:
Ext.regModel('Aanpassen', {
fields: [
{name: 'id', type:'int'},
{name: 'route_id', type:'int'},
{name: 'locnaam', type:'string'},
{name: 'latitude', type:'string'},
{name: 'longitude', type:'string'},
{name: 'image', type:'string'},
{name: 'audio', type:'string'},
{name: 'beschrijving', type:'string'},
{name: 'adres', type:'string'},
{name: 'actief', type:'string'},
{name: 'leaf', type:'boolean'},
{name: 'type', type:'string'},
{name: 'title', type:'string'},
{name: 'items', type:'array'}
]
});
So what happens is, while I receive the following information for each sub-item, from the server:
Code:
- active : "true"
- adres : "Bergelen 56, Kortrijk"
- audio: "1.mp3"
- beschrijving: "Immobilier (locations Saisonnieres Et Temporaires) "
- id: "1"
- image: "1.jpg"
- latitude: ""
- leaf: true
- locnaam: "Bigsand"
- longitude: ""
- route_id: "2"
- title: "Bigsand"
- type: "locatie"
This is what each item has when stored in the TreeStore using .setProxy() method.
Code:
- actief: ""
- adres: ""
- audio: "1.mp3"
- beschrijving: "Immobilier (locations Saisonnieres Et Temporaires) "
- id: 1
- image: "1.jpg"
- items: ""
- latitude: ""
- leaf: true
- locnaam: "Bigsand"
- longitude: ""
- route_id: 1
- tag: "div"
- title: "Bigsand"
- type: "locatie"
As you can see, not all the data gets forwarded correctly. 2 fields (actief and adres) are missing some information.
Would really appreciate any hint/tip.
Thanks in advance.