Ext Store is not loading data correctly
I am really stuck o开发者_开发技巧n this and would be very grateful for any hints. When I try to load my 'dealerList' store:
updateDealerList : function (){
myapp.stores.dealerList.load();
}
Edit: nevermind, finally solved it myself... stores work when I stop using the associations
The reason is you have things configured incorrectly.
Your DealerList Model is mapped to currentPage, totalPages, dealers but the reader has a root of dealers. The way you have it set up the JSON should look like this:
{
dealers : [
{
currentPage : 0,
totalPages : 10,
dealers : [....]
}
]
}
But this isn't what you want. Using your JSON from your PHP file, this is what your Model + Store should look like:
Ext.regModel('DealerList', {
fields : [
'dealerName'
]
});
myapp.stores.dealerList = new Ext.data.Store({
model : 'DealerList',
proxy : {
type: 'ajax',
url : 'dealerresults.php',
extraParams: {
app_id: '<?php echo $app_id; ?>',
arrayParam: ['value1', 'value2']
},
reader: {
type: 'json',
root: 'dealers',
}
}
});
The reader will take the entire JSON string and parse it. Based on the root specified in the reader, that is where it looks for the records you want so 'dealers' in your JSON is where your records are.
精彩评论