PDA

View Full Version : problems with the datastore



ballibum
9 Nov 2009, 6:00 AM
Hello forum,
i´ve got some problems with my datastore.
I want to create a combobox with the datas from an extern data. at first i am creatting a php-data:

$dateizeiger=fopen($datei,"r");
while(!feof($dateizeiger))
{

$zeile= fgets($dateizeiger);
$zeile=str_replace(" ", ",", $zeile);
do
{
$zeile=str_replace(",,", ",", $zeile);
}
while (strstr($zeile,",,")== true);

$teile=explode(",",$zeile);

echo "{datei:'$teile[0]'";
echo ",ort:'$teile[1]'";
echo ",jahr:'$teile[2]'},<br>";

}
}
fclose($dateizeiger);

?>

if i am testing these php-code i am getting the following text:

{datei:'paso_501.05',ort:'Aachen',jahr:'2005'},
{datei:'pasoE626.05',ort:'Alfhausen',jahr:'2005'},
{datei:'paso_hep.05',ort:'Allmendfeld',jahr:'2005'},
{datei:'paso_291.05',ort:'Angermünde',jahr:'2005'},
{datei:'pasoB488.05',ort:'Anklam',jahr:'2005'},
{datei:'paso_460.05',ort:'Artern',jahr:'2005'}

over a jsonreader i want to create a new datastore for the combobox:

storeStationen=new Ext.data.JsonStore({
autoDestroy: true,
url: '../wetter.php',
storeId: 'wetterstationen',
idProperty: 'datei',
fields: ['datei', 'ort', 'jahr']
});
and with:

// JavaScript Document
stationsauswahl = new Ext.form.ComboBox({
store: storeStationen,
displayField: 'ort',
mode: 'local',
triggerAction: 'all',
emptyText: 'Wählen Sie ein Ort...',
selectOnFocus: true,
autowidth: true,
getListParent: function() {
return this.el.up('.x-menu');
},
iconCls: 'no-icon'
});
i generating a selctfield.

in my application i can see the selectfield where i want, but it is an emptybox without any values.
why? where is my misstake?
thanks for helping me!!!!!
and sorrie for my bad english.

Animal
9 Nov 2009, 6:14 AM
The store is not loaded which it must be if the ComboBox is mode: 'local'

Configure it with autoLoad: true, and it will load when you construct it.

ballibum
10 Nov 2009, 12:08 AM
nothing changed.
so is there a way to check with firebug if the datastore is load?

Animal
10 Nov 2009, 12:20 AM
Yes.

Look at it.

ballibum
10 Nov 2009, 12:48 AM
mh, i can not see anything, firebug does not show any error, but also no dataloading

Animal
10 Nov 2009, 1:00 AM
No XHR?

When configured autoLoad: true?

You'll have to set a breakpoint in Store.load, and if it gets there step through, and if not, find out why.

ballibum
10 Nov 2009, 3:38 AM
now i get a message an can see that the store is load, but without the json-parameters. if i am opening the link GET http://localhost/wetter.php?_dc=1257852319552
i have the "fields" paramters, header and answer, so is that a real json-request?
by answer i am getting these:



{
"datei": "paso_501.05",
"ort": "Aachen",
"jahr": "2005"
},
{
"datei": "pasoE626.05",
"ort": "Alfhausen",
"jahr": "2005"
},
{
"datei": "paso_hep.05",
"ort": "Allmendfeld",
"jahr": "2005"
},
{
"datei": "paso_291.05",
"ort": "Angermünde",
"jahr": "2005"
},
{
"datei": "pasoB488.05",
"ort": "Anklam",
"jahr": "2005"
},
{
"datei": "paso_460.05",
"ort": "Artern",
"jahr": "2005"
},
{
"datei": "paso_575.05",
"ort": "Aue",
"jahr": "2005"
},
{
"datei": "paso_au.05",
"ort": "Auweiler",
"jahr": "2005"
},
{
"datei": "paso_av.05",
"ort": "Avelsbach",
"jahr": "2005"
},
{
"datei": "paso_bac.05",
"ort": "Bacharach",
"jahr": "2005"
}

Animal
10 Nov 2009, 3:44 AM
That is the entire content of the response packet?

(BTW, to help those who read your code, feed it through http://jsbeautifier.org/ first, and post it in
... tags.

ballibum
10 Nov 2009, 3:53 AM
okay, i will do it.
yes, that is the whole content of the answering.

Animal
10 Nov 2009, 3:57 AM
Then read this again: http://www.extjs.com/deploy/dev/docs/?class=Ext.data.JsonReader