PDA

View Full Version : bindstore API documentation callback



italoc
31 Aug 2009, 6:51 AM
i need the documentation of the BINDSTORE function?

i neeed to dynamically change the content of the store and after that i need to select a defined value...

with this code the store was changed but don select the correct value the first time...



dataEndEdit.bindStore(storeDataEnd); //store reloaded ok
dataEndEdit.setValue('value'); //don't work the first time


i think that i need a callback for bindstore function


can you help me???

Condor
31 Aug 2009, 6:56 AM
No you don't.

It think you have a different problem. Could you elaborate on what you are trying to do and post some more code and examples of the data in the stores?

italoc
31 Aug 2009, 7:14 AM
i have a store whit date (dynamically generete) as ValueFiled and a static name (for example "3 months") as DisplayField every time that i change a datestart value the store is regenerated with new Valuefiled and with the same DisplayField.

i need to select a default value (always diffent) every time that the store is reload.

this is the code:



var storeDataEnd = new Ext.data.JsonStore({
data: {
"data": [{
"value": "",
"data": ""
}]
},
root: 'data',
fields: ['value', 'data']
});


var dataEndEdit = new Ext.form.ComboBox({
fieldLabel: 'Durata Trattamento',
id: 'editdataend',
xtype: 'combo',
field: ['data', 'value'],
displayField: 'data',
valueField: 'value',
triggerAction: 'all',
forceSelection: true,
lazyInit: false,
name: 'dataend',
mode: 'local',
store: storeDataEnd,
typeAhead: true,
emptyText: 'Seleziona il Termine...',
allowBlank: false
});


the store is populated in this way



var storeDataEnd = new Ext.data.JsonStore({
data: {
"data": [{
"value": dataStart.getValue().add(Date.MONTH, 1),
"data": "1 mese"
}, {
"value": dataStart.getValue().add(Date.MONTH, 3),
"data": "3 mesi"
}, {
"value": dataStart.getValue().add(Date.MONTH, 6),
"data": "6 mesi"
}, {
"value": dataStart.getValue().add(Date.DAY, 21),
"data": "21 giorni"
}, {
"value": dataStart.getValue().add(Date.DAY, 14),
"data": "14 giorni"
}, {
"value": dataStart.getValue().add(Date.DAY, 7),
"data": "7 giorni"
}, {
"value": dataStart.getValue().add(Date.MONTH, 2),
"data": "2 mesi"
}, {
"value": dataStart.getValue().add(Date.MONTH, 4),
"data": "4 mesi"
}, {
"value": dataStart.getValue().add(Date.MONTH, 5),
"data": "5 mesi"
}]
},
root: 'data',
fields: ['value', 'data']
});

dataEndEdit.bindStore(storeDataEnd);

dataEndEdit.setValue('defaultvalue');// first time don't work.. after manually trigger the combobox this command work


thanks

Condor
31 Aug 2009, 7:29 AM
But you don't have to create a new store at all! You only have to load the new values, e.g.


storeDataEnd.loadData({
"data": [{
"value": dataStart.getValue().add(Date.MONTH, 1),
"data": "1 mese"
},{
"value": dataStart.getValue().add(Date.MONTH, 3),
"data": "3 mesi"
},{
"value": dataStart.getValue().add(Date.MONTH, 6),
"data": "6 mesi"
},{
"value": dataStart.getValue().add(Date.DAY, 21),
"data": "21 giorni"
},{
"value": dataStart.getValue().add(Date.DAY, 14),
"data": "14 giorni"
},{
"value": dataStart.getValue().add(Date.DAY, 7),
"data": "7 giorni"
},{
"value": dataStart.getValue().add(Date.MONTH, 2),
"data": "2 mesi"
},{
"value": dataStart.getValue().add(Date.MONTH, 4),
"data": "4 mesi"
},{
"value": dataStart.getValue().add(Date.MONTH, 5),
"data": "5 mesi"
}]
});

italoc
31 Aug 2009, 8:38 AM
don't work for me... don't load the store...

Condor
31 Aug 2009, 10:04 AM
Please explain... My code should work!

italoc
31 Aug 2009, 11:12 AM
after execution of your code my store is EMPTY... always empty..