PDA

View Full Version : Combobox not loading on page refresh in IE



deepakramana.r
26 Sep 2009, 2:19 AM
I am having 2 comboboxes that use the same store
when i refresh the page in IE the combo box does not gets populated.

countryStore = new Ext.data.SimpleStore({
fields: ['countryId','countryName'],
data : countryData
});

salesCountryCombo = new Ext.form.ComboBox({
id:'ext_salesCountryCombo',
store: countryStore,
//name:'country',
displayField: 'countryName',
valueField: 'countryId',
hiddenName:'countryId',
mode: 'local',
triggerAction: 'all',
selectOnFocus:true ,
//allowBlank:false,
editable:true,
hideTrigger:true,
renderTo : 'createsupplier_salescountrycombo_div',
emptyText:'ALL',
value:'ALL',
valid:'{"valRule":{"ridx":"selectone","ctrid":"sup_type_con"} , "fldName":"Sales Location Address > Country"}',
listeners:
{blur:function()
{
var isPresent = false;
alert(this.getRawValue());
var records = this.store.collect("countryName",false,true);
alert('total-->' + records.length);
for(var i=0;i<records.length;i++)
{
if(records[i]==this.getRawValue())
{
alert('YES');
isPresent = true;
break;
}
}
if(!isPresent){
this.clearValue();
}
}}
});

serviceCountryCombo = new Ext.form.ComboBox({
id:'ext_serviceCountryCombo',
store: countryStore,
//name:'country',
displayField: 'countryName',
valueField: 'countryId',
hiddenName:'countryId',
mode: 'local',
triggerAction: 'all',
selectOnFocus:true ,
valid:'{"valRule":{"ridx":"selectone","ctrid":"sup_type_asp"} , "fldName":"Service Location Address > Country"}',
//allowBlank:false,
editable:true,
hideTrigger:true,
renderTo : 'createsupplier_servicecountrycombo_div',
emptyText:'ALL',
value:'ALL',
listeners:
{blur:function()
{
var isPresent = false;
alert(this.getRawValue());
var records = this.store.collect("countryName",false,true);
alert('total-->' + records.length);
for(var i=0;i<records.length;i++)
{
if(records[i]==this.getRawValue())
{
alert('YES');
isPresent = true;
break;
}
}
if(!isPresent){
this.clearValue();
}
}}

});

Condor
26 Sep 2009, 2:51 AM
Please post properly indented code in [CODE] tags.

countryStore = new Ext.data.SimpleStore({
fields: ['countryId', 'countryName'],
data: countryData
});
salesCountryCombo = new Ext.form.ComboBox({
id: 'ext_salesCountryCombo',
store: countryStore,
//name:'country',
displayField: 'countryName',
valueField: 'countryId',
hiddenName: 'countryId',
mode: 'local',
triggerAction: 'all',
selectOnFocus: true,
//allowBlank:false,
editable: true,
hideTrigger: true,
renderTo: 'createsupplier_salescountrycombo_div',
emptyText: 'ALL',
value: 'ALL',
valid: '{"valRule":{"ridx":"selectone","ctrid":"sup_type_con"} , "fldName":"Sales Location Address > Country"}',
listeners: {
blur: function () {
var isPresent = false;
alert(this.getRawValue());
var records = this.store.collect("countryName", false, true);
alert('total-->' + records.length);
for (var i = 0; i < records.length; i++) {
if (records[i] == this.getRawValue()) {
alert('YES');
isPresent = true;
break;
}
}
if (!isPresent) {
this.clearValue();
}
}
}
});
serviceCountryCombo = new Ext.form.ComboBox({
id: 'ext_serviceCountryCombo',
store: countryStore,
//name:'country',
displayField: 'countryName',
valueField: 'countryId',
hiddenName: 'countryId',
mode: 'local',
triggerAction: 'all',
selectOnFocus: true,
valid: '{"valRule":{"ridx":"selectone","ctrid":"sup_type_asp"} , "fldName":"Service Location Address > Country"}',
//allowBlank:false,
editable: true,
hideTrigger: true,
renderTo: 'createsupplier_servicecountrycombo_div',
emptyText: 'ALL',
value: 'ALL',
listeners: {
blur: function () {
var isPresent = false;
alert(this.getRawValue());
var records = this.store.collect("countryName", false, true);
alert('total-->' + records.length);
for (var i = 0; i < records.length; i++) {
if (records[i] == this.getRawValue()) {
alert('YES');
isPresent = true;
break;
}
}
if (!isPresent) {
this.clearValue();
}
}
}
});

Condor
26 Sep 2009, 2:55 AM
I can't see anything wrong with this code...

Is there anything special about the page (e.g. frameset, iframes etc.)?

deepakramana.r
26 Sep 2009, 3:17 AM
No there is nothing special in the page....

Is there anything wrong with mode:local
actually the data comes from the server..I mean in countryStore i use countryData which comes from server
But the store does not connect to the server to get data...It comes from a separate request fired during page load

Condor
26 Sep 2009, 4:45 AM
Are you sure you are creating the store AFTER the data is received from the server?

deepakramana.r
26 Sep 2009, 4:49 AM
Ya....On page load i fire a request to server...once response comes back i call a method where the countryData is set to the countryStore.

Condor
26 Sep 2009, 4:50 AM
Using the code in your first post or is this a different method?

deepakramana.r
26 Sep 2009, 5:35 AM
Ya..It is the method in my first post...

the countryData in countryStore is a global variable. It is an array which gets initialized during page load.

Condor
26 Sep 2009, 6:16 AM
Changing the data after the store has been loaded doesn't modify the store.

Create the store as:

countryStore = new Ext.data.SimpleStore({
fields: ['countryId', 'countryName'],
data: []
});

and when you received the data call:

countryStore.loadData(countryData);

deepakramana.r
26 Sep 2009, 6:30 AM
I think i dint describe clearly.

i have a method called loadCountry which i have given below.It is the same as in my first post

this method will be called aftre countryData comes from server. So the countrStore is created after countryData comes from server.

which means during page refresh the data will come first and then this method is called.so countryStore is again created on page refresh and countryCombo is also created again and countryStore is assigned to countryCombo

this may be a bad way of coding. but please help


loadCountry()
{
countryStore = new Ext.data.SimpleStore({
fields: ['countryId', 'countryName'],
data: countryData
});
salesCountryCombo = new Ext.form.ComboBox({
id: 'ext_salesCountryCombo',
store: countryStore,
//name:'country',
displayField: 'countryName',
valueField: 'countryId',
hiddenName: 'countryId',
mode: 'local',
triggerAction: 'all',
selectOnFocus: true,
//allowBlank:false,
editable: true,
hideTrigger: true,
renderTo: 'createsupplier_salescountrycombo_div',
emptyText: 'ALL',
value: 'ALL',
valid: '{"valRule":{"ridx":"selectone","ctrid":"sup_type_con"} , "fldName":"Sales Location Address > Country"}',
listeners: {
blur: function () {
var isPresent = false;
alert(this.getRawValue());
var records = this.store.collect("countryName", false, true);
alert('total-->' + records.length);
for (var i = 0; i < records.length; i++) {
if (records[i] == this.getRawValue()) {
alert('YES');
isPresent = true;
break;
}
}
if (!isPresent) {
this.clearValue();
}
}
}
});
}