PDA

View Full Version : Simple Reload of ComboBox



sberringer
31 Aug 2007, 7:30 AM
I have scoured the forum, but have not really found an answer for this simple task. I have a combo box, created at page load, that needs to be reloaded with different data on some event.

// Initial load looks like:
var StudentDataSrc = [
['test','0']
];
var StudentDataStore = new Ext.data.SimpleStore({
fields: ['Description', 'Value'],
data : StudentDataSrc
});
var ComboStudents = {store: StudentDataStore, displayField:'Description', valueField:'Value', typeAhead:true, mode:'local', allowBlank:false, forceSelection:true, selectOnFocus:true, emptyText : 'Select a student...'};

// After an event (blur on text field) I am trying to reload with another set of data:
var xxx = [
['S0','0'],
['s1', '1'],
['s2', '2'],
['s3', '3']
];

var Sds = new Ext.data.SimpleStore({
fields: ['Description', 'Value'],
data : xxx
});
fieldStudents.store.loadData(Sds);

Above does not work, just clears out the combobox

Any help would be appreciated, thanks.

fay
31 Aug 2007, 7:56 AM
loadData() does not load another store, but a block of data. See http://extjs.com/deploy/ext/docs/output/Ext.data.Store.html#loadData

See also:


http://extjs.com/forum/showthread.php?t=11068

http://extjs.com/forum/showthread.php?p=32148#post32148


Your code should be:


fieldStudents.store.loadData(xxx);

Note: When posting code please use the CODE tags - select your code and click # in the editor bar.

battisti
14 Mar 2008, 4:37 AM
[CODE]
// cria o vetor que ir