PDA

View Full Version : Nested Combobox



crocop21
19 Jun 2012, 7:37 AM
Hi all, i am try to implement a nested Combobox with extjs4 i have all right i think, but the problem is in my function when i try to load my store in the combo here is my error:

records.get is not a function

And here is mi code in my Controller:


onComboboxSelect: function(combo, records, options) {

var form = Ext.getCmp('state');
console.info(form);


var store = form.getStore();
form.enable();
form.clearValue();
store.load({params:{id: records.get('value')}});
}



Thanks..

scottmartin
19 Jun 2012, 10:07 AM
Have you evaluated records to see if the object is valid? What are you using to debug?

Scott.

crocop21
19 Jun 2012, 10:35 AM
Have you evaluated records to see if the object is valid? What are you using to debug?

Scott.

Yes the object is valid, firebug

scottmartin
19 Jun 2012, 10:41 AM
records is array .. please try the following:



// The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data : [
{"abbr":"AL", "name":"Alabama"},
{"abbr":"AK", "name":"Alaska"},
{"abbr":"AZ", "name":"Arizona"}
//...
]
});

// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
renderTo: Ext.getBody(),
listeners: {
select: function(combo,records,opts) {
console.log(records.data.name);
}
}
});​


Scott.

crocop21
19 Jun 2012, 12:23 PM
records is array .. please try the following:



// The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data : [
{"abbr":"AL", "name":"Alabama"},
{"abbr":"AK", "name":"Alaska"},
{"abbr":"AZ", "name":"Arizona"}
//...
]
});

// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
renderTo: Ext.getBody(),
listeners: {
select: function(combo,records,opts) {
console.log(records.data.name);
}
}
});​


Scott.
mmm but the question is how can reload the store for can load my state from my id who give me my country?

i try form.getStore().load({params:{'id': comb.getValue('value')

but is show me the countrys not the states :s

36353

scottmartin
19 Jun 2012, 12:49 PM
Your original problem of records.get('value') has been solved?
Now the issue is loading the secondary combo?

When you make the call using store, is the correct information sent to the server and returned from the server?

Scott.

crocop21
19 Jun 2012, 1:32 PM
Your original problem of records.get('value') has been solved?
Now the issue is loading the secondary combo?

When you make the call using store, is the correct information sent to the server and returned from the server?

Scott.

I think i solve with store.load({params :{id: comb.getValue()
}});
Because i send my id from my function.

id
1


limit
25


page
1


start
0


for my php resolve the state with the id of the country, but i have a problem i think the store is not reload because is sending the same store only the countrys


{"total":5,"data":[{"value":0,"label":"Argentina"},{"value":1,"label":"Espa\u00f1a"},
{"value":2,"label":"M\u00e9xico"},{"value":3,"label":"Per\u00fa"},
{"value":4,"label":"United States"}]}

what about reload in extjs4?

scottmartin
19 Jun 2012, 2:05 PM
what about reload in extjs4?

You can just use store.load()

Scott.

crocop21
20 Jun 2012, 5:09 AM
You can just use store.load()

Scott.

Thanks Scott is working... Only i have a problem, when i reaload my store, my other combo countrys is reload too, i need reaload only the combo states..

combostates.store.load({params :{id: comb.getValue()}});

scottmartin
20 Jun 2012, 5:28 AM
Only the store you provide should load again
Does each combo have it's own store?
Is there any events that would cause the country store to load after a change of states store?

Scott.

crocop21
20 Jun 2012, 6:24 AM
Only the store you provide should load again
Does each combo have it's own store?
Is there any events that would cause the country store to load after a change of states store?

Scott. U are right i had 1 store for both combo i changed i created 2 stores and gave for both combos is working good, only when i try for second time to give a country is doing this

36381

scottmartin
20 Jun 2012, 6:31 AM
Is the data in your header as expected the 2nd time?

Also have a look at lastQuery:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.ComboBox-property-lastQuery

Scott.

crocop21
20 Jun 2012, 7:11 AM
Is the data in your header as expected the 2nd time?

Also have a look at lastQuery:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.ComboBox-property-lastQuery (http://docs.sencha.com/ext-js/4-1/#%21/api/Ext.form.field.ComboBox-property-lastQuery)

Scott.

Finally i did, i was working with the core of http://extjs.cachefly.net i changed for my local and is working perfect!, Thanks alot Scott..