PDA

View Full Version : Ext.form.ComboBox + Ext.data.Store (with autoLoad: true) -> load data again



Ex_Soft
18 Jun 2010, 5:33 AM
ComboBoxStore3=new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields: ["ID", "VAL"],
root: "rows"
}),
proxy: new Ext.data.HttpProxy({
url: "DataSource2Handler.aspx"
}),
autoLoad: true
})


}, {
xtype: "combo",
id: "ComboBox3",
name: "ComboBox3",
hiddenName: "ComboBox3ID",
fieldLabel: "ComboBox3",
store: ComboBoxStore3,
valueField: "ID",
displayField: "VAL",
width: 240,
emptyText: "Select a make...",
loadingText: "Searching...",
editable: false,
//forceSelection: true,
triggerAction: "all",
//typeAhead: true,
//lazyInit: false,
listeners: {
select: function(f,r,i)
{
if (i == 0)
{
Ext.Msg.prompt("New Value","Value",Ext.emptyFn);
}
}
}
}, {
ComboBoxStore3 was loaded, but ComboBox3 load data again. What must I set to use first load data from ComboBoxStore?

Condor
18 Jun 2010, 5:44 AM
Add mode:'local' to the combobox config ('local' doesn't mean the data has to be local, it only means that the combobox should assume that the data is already loaded).

Ex_Soft
18 Jun 2010, 6:00 AM
mode:'local'
+1 THNX

sothea
28 Feb 2011, 7:56 PM
this is my data store code


var store_sauve = new Ext.data.Store({
id: 'store_sauve',
//writer: writer,
proxy: new Ext.data.HttpProxy({
url: 'reader.php?action=load_sauv',
method: 'POST'
}),
baseParams:{task: "load_sauv"},
autoLoad: true,
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id_sauv'
},
Ext.data.Record.create([
{name: 'id_sauv'},
{name: 'nom_sauv'},
{name: 'nom_sauv_descr'},
]))
});

I have cambobox with datastore. When I remove the window of cambobox many time and then I add some record to cambobox, the new record is not loaded (It is not list in cambobox).


This is my code for cambobox


{
store_sauve.load();
if (!Ext.getCmp('win_load')) {
var win_load = new Ext.Window({
id: 'win_load',
el: 'dl_win_load',
layout: 'fit',
maximizable: true,
width: 650,
height: 180,
closeAction: 'hide',
items: new Ext.FormPanel({
id: 'load',
url:'reader.php?ask=load',
baseParams:{
task: "load",
filtre: 'region'
},
title: 'Chargement des critères',
autoHeight: true,
labelWidth:180,
width:650,
padding: '15 15 15 15',
//layout: 'fit',

items: [new Ext.form.ComboBox({
//triggerAction:'all',
name:'testcombo',
typeAhead:true,
editable: true,
typeAheadDelay: 1000,
mode:'local',
id:'combo_sauv',
store: store_sauve_calc,
fieldLabel:'Sélectionnez votre sauvegarde ',
displayField: 'nom_sauv',
valueField: 'id_sauv',

listeners: {
select: function(combo, record, index){
ciblename=store_sauve_calc.getAt(index).data.nom_cible;
contact=store_sauve_calc.getAt(index).data.contact;
exp_champ=store_sauve_calc.getAt(index).data.exp_champ;
node_site=store_sauve_calc.getAt(index).data.node_site;

comm_sauv.setValue(store_sauve_calc.getAt(index).data.nom_sauv_descr);
},
blur: function (combo){
ciblename=store_sauve_calc.getAt(index_sel).data.nom_cible;
contact=store_sauve_calc.getAt(index_sel).data.contact;
exp_champ=store_sauve_calc.getAt(index_sel).data.exp_champ;
node_site=store_sauve_calc.getAt(index_sel).data.node_site;
}
} //listeners
})]
})
})
}
Ext.getCmp('win_load').show();
}

Condor
28 Feb 2011, 11:36 PM
Since you're using triggerAction:'query', you'll need to call store.clearFilter() before you can see the added records.

sothea
28 Feb 2011, 11:52 PM
Where should I put the clearFilter? I put it before store_sauve.load() but It doesn't work.

I can't get its value by using method Ext.getCmp("..").getValue() but I can get its value by using document.getElementById("..").value.

Condor
1 Mar 2011, 12:21 AM
Could you try to explain your problem better?

sothea
1 Mar 2011, 12:31 AM
I have one panel and In that panel I have 3 buttons "save", "delete" and "load" when I click on save, it is popup new window for save record in the panel. If I click on load, It list all saving name that we save. If I don't close the panel, I can save or load the record normally. If I close it many time, the current saving is not display in "load" but if I delete some saving, It also display.

Condor
1 Mar 2011, 12:59 AM
Are you sure the records are correctly saved to your server?

sothea
1 Mar 2011, 1:02 AM
Yes, I'm sure because I see it in database. When I'm alert the total records(getCount()) in data store, It display the correct number but when I'm alert it in select:function(){}, It display invalid number.

Condor
1 Mar 2011, 1:39 AM
Do you mean the store_sauve or the store_sauve_calc store?

sothea
1 Mar 2011, 1:47 AM
store_save and store_save_calc are the same. I write a wrong words. All store_save_calc are store_save.

Condor
1 Mar 2011, 2:30 AM
Using getCount() from the 'select' event will only return the number of filtered records (because you are using triggerAction:'query').

Try using getTotalCount().

sothea
1 Mar 2011, 3:14 AM
Thank Condor. I found the problem. I use store_sauve.load() for new window "win_load" and I use method hide and show, so the new record is not loaded. The list will display the old record. I can replace store_save.reload() with Ext.getCmp("combo_sauv").load().