1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    3
    Vote Rating
    0
    nagendra8808 is on a distinguished road

      0  

    Default Dynamically change the json-Store root

    Dynamically change the json-Store root


    hi guys sorry for creating this duplicate thread but solution presented in previous thread was not working ..

    I am using extjs 3.4.0 I have a json store as follows

    Code:
    var cat2Store = new Ext.data.JsonStore({
    
    		fields: ['cid','id', 'value'],
    		root: 'cat2',
    		url: 'json/combo2.json'
    		
    	});
    it reads the following json file

    Code:
    {
    cat2:[
    	{
    		cid:'1',
    		id:'1',
    		value : 'A1'
    	},{
    		cid:'1',
    		id:'2',
    		value : 'A2'
    	},{
    		cid:'2',
    		id:'3',
    		value : 'B1'
    	},{
    		cid:'2',
    		id:'4',
    		value : 'B2'
    	}
    	
    	
    	]
    	,
    	cat3:[
    	{
    		cid:'1',
    		id:'1',
    		value : 'C1'
    	},{
    		cid:'1',
    		id:'2',
    		value : 'C2'
    	},{
    		cid:'2',
    		id:'3',
    		value : 'D1'
    	},{
    		cid:'2',
    		id:'4',
    		value : 'D2'
    	}
    	
    	
    	]
    }
    the store is read by a combobox as shown below

    Code:
    {
    				        	xtype: 'combo',
    				        	id : 'combo1',
    				        	hiddenName: 'genre',
    				        	fieldLabel: 'Cat2',
    				        	mode: 'local',
    				        	store: cat2Store,
    				        	displayField:'value',
    				        	valueField:'id',
    				        	triggerAction: 'all',
    				        	listeners: 
    				        	{
    								select :
    								function(e) 
    								{
    									//Help needed here
    								}
    				        	}
    
    				        }
    my question is how do i change the root of my store from cat2 to cat3 on the select event of the combobox

  2. #2
    Sencha User
    Join Date
    Oct 2010
    Location
    Knoxville, TN
    Posts
    133
    Vote Rating
    1
    Kcarpenter is on a distinguished road

      0  

    Default


    You are in the wrong section, these threads relate to EXTJS 4.x not 3.x.
    But to answer your question,
    I think you can do.

    getStore().getProxy().root = 'newRoot';
    getStore().getProxy().url = 'new url'
    getStore.load();

    Its been a few months since I've touched 3.0 stores though.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    37
    Vote Rating
    0
    sanova is on a distinguished road

      0  

    Default


    Is there a way to do that in version 4 ?

    I have to change root parameters of JsonStore inside a listeners of a Master Grid.


    Thanks