-
29 Jul 2010 4:26 AM #1
Several dependent Comboboxes in the form. How it works?
Several dependent Comboboxes in the form. How it works?
I have form, which included several comboboxes (country, region, city, street). Each of combo depended from previous combo (by his selected id) except first (country).
This value transferred through baseParams?
MyCode (country, region):
How to do it right?Code:var fieldSetAddress = { xtype : 'fieldset', title : 'Адрес', flex : 1, border : false, labelWidth : 60, defaultType : 'textfield', defaults : { anchor : '-5', allowBlank : false }, items : [ { xtype:'combo', width:'98%', fieldLabel: 'Страна', displayField:'name', loadingText:'Загрузка...', emptyText:'Выберите страну...', name: 'countryId', triggerAction: 'all', autocomplete: true, store: new Ext.data.JsonStore({ root : 'results', idProperty: 'id', totalProperty : 'total', fields : [ { name : 'name', mapping : 'name' },{ name : 'id', mapping : 'id' } ], proxy : new Ext.data.ScriptTagProxy({ method: 'POST', url : './addresses/getlistcountries/' }) }) },{ xtype:'combo', width:'98%', fieldLabel: 'Регион', name: 'regionId', displayField:'name', autocomplete: true, fieldLabel: 'Регион', forceSelection: true, loadingText:'Загрузка...', triggerAction: 'all', valueNotFoundText: 'Выберите регион...', emptyText:'Выберите регион...', store: new Ext.data.JsonStore({ idProperty: 'id', root : 'results', totalProperty : 'total', baseParams : { countryId : 0 }, fields : [ { name : 'name', mapping : 'name' },{ name : 'id', mapping : 'id' } ], proxy : new Ext.data.ScriptTagProxy({ method: 'POST', url : './addresses/getlistregions/' }) }), }] };
Thx
-
29 Jul 2010 5:39 AM #2
For a start, why are you using ScriptTagProxy?
But your second one just needs a beforeload listener on the Store to add a parameter to the params option to carry the value from the previous combo.Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
29 Jul 2010 6:21 AM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
No, beforeload of the second combobox store is only fired once with triggerAction:'all'. You'll need to force it to load again from the select event of the first combobox, e.g.
Code:combobox1.on('select', function(combo, record){ var bp = combobox2.store.baseParams; if (!bp || bp.parentId != record.id) { combobox2.store.setBaseParam('parentId', record.id}; // pass selected id when loading second combobox combobox2.clear(); // current value of combobox2 is no longer valid delete combobox2.lastQuery; // force loading of combobox2 when used next } });
-
29 Jul 2010 6:41 AM #4
What Proxy i must use? Or just write url in combo params?For a start, why are you using ScriptTagProxy?
My formPanel is a company information. I want use he for create & edit company data.No, beforeload of the second combobox store is only fired once with triggerAction:'all'. You'll need to force it to load again from the select event of the first combobox, e.g.
This will be work, when i call load() FormPanel, which include this combo-fields, for editing company?
Thx for reply!
-
29 Jul 2010 6:57 AM #5
Use an HttpProxy unless you are talking to a server on another domain which uses JSON-P
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
29 Jul 2010 11:53 AM #6
clear() does not work (( But it works without this line of code.Code:combobox2.clear(); // current value of combobox2 is no longer valid
-
29 Jul 2010 12:37 PM #7Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
Sorry, the method is called clearValue() and not clear().
Similar Threads
-
Form : 2 multselect dependent
By yegortitov in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 8 Dec 2009, 1:43 AM -
Multiple dependent ComboBoxes to be filled on event
By mw-flow in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 23 Sep 2009, 12:53 AM -
Dependent form Field
By kordsmen in forum Ext 1.x: Help & DiscussionReplies: 0Last Post: 17 Jul 2007, 9:05 AM -
2 Comboboxes on one form, one works one doesn't - same syntax
By amygrant in forum Ext 1.x: Help & DiscussionReplies: 6Last Post: 24 Jun 2007, 3:33 AM



Reply With Quote