PDA

View Full Version : dataStore.on('load ... not working



zefyrus
23 Aug 2007, 11:42 AM
Hi all

I have this code:

[CODE]Ext.QuickTips.init();
function formatBoolean(value){
return value ? 'Sim' : 'Não';
};

// shorthand alias
var fm = Ext.form, Ed = Ext.grid.GridEditor;

var Medias = Ext.data.Record.create([
{name: 'id_midia', type: 'int'},
{name: 'nome', type: 'string'},
{name: 'link', type: 'string'},
{name: 'id_cidade', type: 'int'}
]);

ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'mediaListJson.php'
}),

// create reader that reads the Topic records
reader: new Ext.data.JsonReader({
// records will have an "Item" tag
root: 'dados',
id: 'id_media',
totalProperty: 'total'
}, Medias),

remoteSort: false
});

var Cities = Ext.data.Record.create([
{name: 'id_cidade', type: 'int'},
{name: 'id_estado', type: 'int'},
{name: 'cidade', type: 'string'},
{name: 'estado', type: 'string'}
]);

dsMN = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'citiesJson.php'}),

reader: new Ext.data.JsonReader({
root: 'dados',
id: 'id_cidade',
cidade: 'cidade',
estado: 'estado'
}, Cities)
});

function formatCities(value){
var pValue = dsMN.getById(parseInt(value));
if (pValue){
alert(pValue);
alert(pvalue.get('cidade'));
alert(pValue.dados.cidade);
alert(pValue.cidade);
return pValue.data.cidade;
}else{
return 'Cidade n

fay
23 Aug 2007, 12:09 PM
// trigger the data store load
ds.load();
}); // What's this?

dsMN.load();

It's hard to tell from your code formatting if the actual dsMN.load() is being called. Are you also sure that citiesJson.php is actually loading anything? Simplify the code to make it easier to debug - remove everything except for the creation of dsMN, a "dummy" .on('load') for it, and a call to dsMN.load().