PDA

View Full Version : ComboBox whith datastore gives a blank page !



blacksword888
11 Jun 2011, 2:47 AM
Hi,
I'm trying to add a combobox to a formPanel , when i connect this combox with a datastore , it gives me a blank page , when i delete only its store property , i get my FormPanel displayed with other fields

Thank you :)

skirtle
11 Jun 2011, 2:59 AM
You'll need to post the code for your combobox and store. Please use code tags (# icon in the editor) and preview your post prior to submitting to make sure it is readable.

blacksword888
11 Jun 2011, 5:16 AM
This is the code that isn't working


var simple = new Ext.FormPanel({
url:'save-form.php',
id :'simple',
autoScroll :'auto',
frame:true,
title: 'Ajouter Medecin',
bodyStyle:'padding:5px 5px 0',
width: 500,
defaultType: 'textfield',

items: [
{
fieldLabel: 'Nom',
id: 'nomMedecin',
anchor:'100%',
allowBlank:false
},
{
fieldLabel: 'Prenom',
id :'prenomMedecin',
anchor:'100%',
allowBlank:false
},{
fieldLabel: 'Secteur',
id: 'secteurMedecin',
anchor:'100%',
allowBlank:false
},new Ext.form.ComboBox({
store :SpecialiteDataStore,
displayField:'nomSpecialite', // we have two indexes, ID and Name
typeAhead: true,
mode: 'remote',
triggerAction: 'all',
selectOnFocus:true,
fieldLabel: 'Nom',
id :'put1',
name : 'nomCab',
anchor:'100%'
}),
new Ext.form.RadioGroup({
fieldLabel: 'Potentiel',
vertical: false,
id:'potentielMedecin',
items: [
{boxLabel: 'A', name: 'pot'+num, inputValue: 'a'},
{boxLabel: 'B', name: 'pot'+num, inputValue: 'b'},
{boxLabel: 'C', name: 'pot'+num, inputValue: 'c'}
]})
],
buttons: [
{
text: 'Ajouter medecin ',
align :'left',
handler: createMedecin
},{
text: 'Ajouter etablissement ',
align :'left',
handler: addEtablissement
},{
text: 'Annuler ',
handler: function(){
myWin.hide();
resetFields();
simple.getForm().reset();

}
}]
});

This one is working


var simple = new Ext.FormPanel({
url:'save-form.php',
id :'simple',
autoScroll :'auto',
frame:true,
title: 'Ajouter Medecin',
bodyStyle:'padding:5px 5px 0',
width: 500,
defaultType: 'textfield',

items: [
{
fieldLabel: 'Nom',
id: 'nomMedecin',
anchor:'100%',
allowBlank:false
},
{
fieldLabel: 'Prenom',
id :'prenomMedecin',
anchor:'100%',
allowBlank:false
},{
fieldLabel: 'Secteur',
id: 'secteurMedecin',
anchor:'100%',
allowBlank:false
},new Ext.form.ComboBox({
// store :SpecialiteDataStore,
displayField:'nomSpecialite',
typeAhead: true,
mode: 'remote',
triggerAction: 'all',
selectOnFocus:true,
fieldLabel: 'Nom',
id :'put1',
name : 'nomCab',
anchor:'100%'
}),
new Ext.form.RadioGroup({
fieldLabel: 'Potentiel',
vertical: false,
id:'potentielMedecin',
items: [
{boxLabel: 'A', name: 'pot'+num, inputValue: 'a'},
{boxLabel: 'B', name: 'pot'+num, inputValue: 'b'},
{boxLabel: 'C', name: 'pot'+num, inputValue: 'c'}
]})
],
buttons: [
{
text: 'Ajouter medecin ',
align :'left',
handler: createMedecin
},{
text: 'Ajouter etablissement ',
align :'left',
handler: addEtablissement
},{
text: 'Annuler ',
handler: function(){
myWin.hide();
resetFields();
simple.getForm().reset();

}
}]
});and here is the code of my store :


SpecialiteDataStore = new Ext.data.Store({
id: 'SpecialiteDataStore',
proxy: new Ext.data.HttpProxy({
url: 'database.php',
method: 'POST'
}),
baseParams:{task: "LISTINGSPECIALITE"}, // this parameter is passed for any HTTP request
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{name: 'nomSpecialite', type: 'string', mapping :'nomSpecialite'}
])
});
i also want to say that the store is working, i'm using it in a comboBox that is dynamicly added to my formPanel

Thx for ur answers :)

skirtle
12 Jun 2011, 1:16 AM
OK, I've given your code a go and it all seems to work fine for me.

Here are some things you should try...


Cut back all of the other code apart from the bit that's failing. For example, try removing the buttons and the other form items. Not only can this often provide valuable insight into the nature of the problem but also it is this minimal example that you should be posting to the forums, not your full code. You'll get help much faster that way.
Try running the code in different browsers and let us know what the error messages say. Most browsers have pretty good error logging and debuggers these days, Firefox's Firebug and Chrome's Developer Tools are both very popular. Most will give you the exact line number that the problem occurred on and the chance to jump to that line in the code. Sometimes such messages just take you deep into the bowels of Ext but more often than not there's something in the stacktrace that reveals all.
The only theory I have that fits the behaviour you've described is that SpecialiteDataStore isn't declared at the point you try to use it in your combobox. Is it definitely defined before you try to use it and is that variable in scope? Are you able to log out the value of that variable just prior to using it in the combobox (if you're using Firebug or Chrome then use console.log() or console.dir() to log it out)?


HTH.

blacksword888
12 Jun 2011, 5:25 AM
Thx Skirtle for ur answer , as you said , i tried to use the datastore before i defined it :D

it's working now........Have a good day :)