1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    7
    Vote Rating
    0
    pconley312 is on a distinguished road

      0  

    Default Answered: Changing data during the proxy load

    Answered: Changing data during the proxy load


    I have a situation where I would like to alter the data that is being downloaded via my ajax call before it gets loaded onto the view associated with a store. I have tried a couple of things ... the latest attempt (below) was to use the call back in the load. But this does not seem to actually change the records. The actual change I want to make is to substitute the given url with a data-url - but my example below just alters the name.

    Any suggestions?

    Code:
    var loadedToken = false;
    
    Ext.define('sator.controller.Projects', {
        extend: 'Ext.app.Controller',
       
        config: {	
    		stores: ['Project'],	
            refs: {
                projects: "projects"
            },
            control: {
    			'projects' : { show: 'showProjects'},
                            'projects list': { itemtap: 'showProject' }
            }
        },
    
    
    	showProjects: function(){ 		
    		console.log("show projects");
    		if( session && session.Token && (session.Token != loadedToken) ){
    			console.log("...a new session exists ");
    			var store = Ext.getStore("Project");
    			store.setProxy({
    				type: 'ajax',
                                    url: 'scripts/getprojects.php?token='+session.Token,
                                    reader: {
                    	             type: 'json',
                     	             rootProperty: 'entries'
                                    }           	
    			});	
    			//store.load();			
    			store.load({
    				callback: function(records, operation, success) {
    					for( var index in records ){
    						console.log( records[index].data.ProjID );
    						records[index].data.Name = "Riddle Me This, Batman!";
    					}
    				}
    			});			
    			
    			loadedToken = session.Token;
    			console.log('...loaded project records');
    		}
    	},
    
    
    	showProject: function(list, index, element, record){ 
    		console.log(record.get('Name')); 
    		console.log("token = "+session.Token);		
    		// the ref above creates the accessor getProjects		
    		var view = this.getProjects();	// see ref above	
    		// view  is a navigator view onto which we can "push" a new view
    		view.push({
    			xtype: 'panel',
    			title: record.get('Name'),
    			//html: record.get('content'),
    			//scrollable: true,
    			styleHtmlContent: true			
    		});
    	}
    });
    Last edited by mitchellsimoens; 5 Apr 2012 at 4:45 AM. Reason: added [CODE] tags

  2. You should use the set method as much as possible, meaning not do

    Code:
    records[index].data.Name = '...';
    If Name is the field then do this:

    Code:
    records[index].set('Name', 'some value');

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,673
    Answers
    3355
    Vote Rating
    749
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You should use the set method as much as possible, meaning not do

    Code:
    records[index].data.Name = '...';
    If Name is the field then do this:

    Code:
    records[index].set('Name', 'some value');
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    7
    Vote Rating
    0
    pconley312 is on a distinguished road

      0  

    Default


    I think I got this to work by changing
    records[index].data.Name = "Riddle Me This, Batman!";
    to
    records[index].set("Name","sdkljfsldkfj");

  5. #4
    Sencha User
    Join Date
    Apr 2012
    Posts
    7
    Vote Rating
    0
    pconley312 is on a distinguished road

      0  

    Default


    yep that worked... our posts overlapped

Thread Participants: 1

Tags for this Thread

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