1. #1
    Ext User mrileyaz's Avatar
    Join Date
    Feb 2008
    Location
    Phoenix, AZ
    Posts
    19
    Vote Rating
    0
    mrileyaz is on a distinguished road

      0  

    Question Transfer data from one store to another store

    Transfer data from one store to another store


    I have a FormPanel. This form triggers a JsonStore to get data from the database. The store populates a second store. The second store populates a GridPanel. Each time the form is submitted, I need the data from the first store to be added (appended) into the second store, not replace it. Currently when I refresh the grid, the resultset from the second query replaces the first.

    Is there a public method for one of these objects I do not know about?

    Code samples follow:


    The form triggers this store. Assume baseParams maps to: form.getForm().getValues()

    PHP Code:
      var dsUsersProxy = new Ext.data.JsonStore({
          
    url'./?event=ajax.groupMempers.do',
                  
    baseParamsbaseParams,
                  
    autoLoadtrue,
          
    root'data',
          
    fields: ['displayvalue''rowid']
      }); 
    This is the second store. Assume JReader maps to a JsonReader which has a Record.create().

    PHP Code:
      var dsUsers = new Ext.data.Store({
                  
    readerJReader
      
    }); 
    This loads the data from the first store into the second store. This is where the problem is. I have used add() and insert() and both replace the existing data. There is no JS error but the data is overwritten. I have verified this with console.dir(dsUsers)

    PHP Code:
      dsUsersProxy.on('load', function(){
                  var 
    userRecords dsUsersProxy.getRange();
                  
    //dsUsers.add(userRecords);
                  
    dsUsers.insert(0userRecords);
                  
    console.log(dsUsers.data.length);
      }); 

  2. #2
    Ext User mrileyaz's Avatar
    Join Date
    Feb 2008
    Location
    Phoenix, AZ
    Posts
    19
    Vote Rating
    0
    mrileyaz is on a distinguished road

      0  

    Exclamation Wrong Forum

    Wrong Forum


    Sorry, this was supposed to go in Ext Community Forums (2.0). I will re-post there.

  3. #3
    Ext JS Premium Member Foggy's Avatar
    Join Date
    Apr 2007
    Location
    Switzerland
    Posts
    477
    Vote Rating
    0
    Foggy is on a distinguished road

      0  

    Default


    While this solution is not perfect, it just work

    Code:
    	prepareData : function(selections) {
    		var data = new Array();
    		
    		Ext.each(selections, function(record) {
    			var to = {
    				advice : record.data.advice,
    				name : record.data.name
    			}
    			data.push(to);
    		}.createDelegate(this));
    		
    		
    		var o = {
    			totalCount : selections.length,
    			data : data
    		}
    		
    
    
    
    		// damn im stupid, this should work too instead the lines above...
    		var o = {
    			totalCount : selections.length,
    			data : selections
    		}	
    
    
    		this.ds = new Ext.data.JsonStore({
    			root: 'data',
    			fields: [
    				'advice', 
    				'name'
    			],
    			sortInfo:{field: 'name'}
    		});
    		this.ds.loadData(o);					
    	},
    
    	init : function() {
    		this.prepareData(otherGrid.selModel.getSelections());
    	}

  4. #4
    Ext User cerad's Avatar
    Join Date
    Dec 2007
    Posts
    226
    Vote Rating
    0
    cerad is on a distinguished road

      0  

    Default


    dsUsers.insert(dsUsers.getCount(), userRecords);

  5. #5
    Ext User mrileyaz's Avatar
    Join Date
    Feb 2008
    Location
    Phoenix, AZ
    Posts
    19
    Vote Rating
    0
    mrileyaz is on a distinguished road

      0  

    Default


    2.0 thread can be found here:
    http://extjs.com/forum/showthread.php?p=138082

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