1. #1
    Ext User
    Join Date
    Apr 2010
    Location
    Russia,Tver
    Posts
    24
    Vote Rating
    0
    Tpona is on a distinguished road

      0  

    Default 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):

    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/'
    	            	})
    	            }),
    	       }]
    	};
    How to do it right?
    Thx

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    35
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    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.

  3. #3
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    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
      }
    });

  4. #4
    Ext User
    Join Date
    Apr 2010
    Location
    Russia,Tver
    Posts
    24
    Vote Rating
    0
    Tpona is on a distinguished road

      0  

    Default


    For a start, why are you using ScriptTagProxy?
    What Proxy i must use? Or just write url in combo params?

    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.
    My formPanel is a company information. I want use he for create & edit company data.
    This will be work, when i call load() FormPanel, which include this combo-fields, for editing company?

    Thx for reply!

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    35
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Use an HttpProxy unless you are talking to a server on another domain which uses JSON-P

  6. #6
    Ext User
    Join Date
    Apr 2010
    Location
    Russia,Tver
    Posts
    24
    Vote Rating
    0
    Tpona is on a distinguished road

      0  

    Default


    Code:
    combobox2.clear(); // current value of combobox2 is no longer valid
    clear() does not work (( But it works without this line of code.

  7. #7
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    Sorry, the method is called clearValue() and not clear().

Similar Threads

  1. Form : 2 multselect dependent
    By yegortitov in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 8 Dec 2009, 1:43 AM
  2. Multiple dependent ComboBoxes to be filled on event
    By mw-flow in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 23 Sep 2009, 12:53 AM
  3. Dependent form Field
    By kordsmen in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 17 Jul 2007, 9:05 AM
  4. 2 Comboboxes on one form, one works one doesn't - same syntax
    By amygrant in forum Ext 1.x: Help & Discussion
    Replies: 6
    Last Post: 24 Jun 2007, 3:33 AM

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar