PDA

View Full Version : Store read method not working for me



parky128
19 Oct 2010, 3:06 AM
Hi,

I have a problem getting an array store to reload data from my configured proxy. I'm trying to make use of the read method on my unitStore object on my toolbar refresh button handler:



buildStore: function() {

unitStore = new Ext.data.Store({
autoLoad: true,
model: "Unit",
proxy: {
type: 'ajax',
url : 'GetData.ashx',
reader: {
type: 'array',
root: 'data',
idProperty: 'UntID'
}
},

listeners: {
'load': function() {
if(UIBuilt==false)this.buildUI()
}, scope:this
}
});

unitStore.sort('LastUpdateDTUTC', 'DESC');
},

buildUI : function() {

map = new Ext.Map({
title: 'Map',
getLocation: true,
mapOptions: {
zoom: 12
}
});

timeline = new Ext.List({
title: 'Detail',
store: unitStore,
scroll: 'vertical',
cls: 'unitList',
tpl: tpl,
autoHeight:true,
itemSelector: 'div.unit',
singleSelect: true
});


panel = new Ext.TabPanel({
fullscreen: true,
animation: 'slide',
items: [map, timeline]
});

var tabBar = panel.getTabBar().add([{
flex:1
},{
xtype:'button',
ui: 'action',
text: 'Refresh',
handler: unitStore.read()
//iconCls: 'refresh'
}]);
panel.getTabBar().doLayout();


unitStore.each(this.addMarker);
map.map.fitBounds(bounds);

UIBuilt = true;

}

But I get an error in Chrome saying Object has no method 'call', being thrown from the depths of the touch debug js file.

I only used the read method as I came across this in other forum posts, but see it's not in the API docs, is there a different method I should be using to refresh my store?

I did try out the load method but get the same error message thrown.

Thanks, Rob

evant
19 Oct 2010, 3:09 AM
Left as an exercise to the reader:



function f(){
return 1;
}

var x = f;
var y = f();

console.log(x);
console.log(y);

parky128
19 Oct 2010, 3:14 AM
Sorry Evan, but I dont know what you mean by this reply.

evant
19 Oct 2010, 3:24 AM
Well, what you've basically done is:



handler: f()


As in, you've passed the result of the function as the handler property, as opposed to a reference to the function.

parky128
19 Oct 2010, 3:30 AM
Ah...

Changed to:


handler: function() {
unitStore.read()
}

And I'm now seeing what the XHR calls to retrieve my data!

Thanks