1. #1
    Ext User
    Join Date
    Mar 2008
    Posts
    11
    Vote Rating
    0
    marinica is on a distinguished road

      0  

    Question Problem loading data in JsonStore

    Hello everyone,

    I have a JsonStore object which cannot load data.
    Each time the load should be done I get load exception which parameter 'name' has value TypeError (name: TypeError).
    The data for JsonStore got from server are:

    {"Clocks":[{"id":"1","clock_in":"0000-00-00 00:00:00","clock_out":"0000-00-00 00:00:00","seconds":"5000","correction":"0","corrected_clock_in":"0000-00-00 00:00:00","corrected_clock_out":"0000-00-00 00:00:00","is_corrected":"0","correcter":"13","time_of_correction":"0000-00-00 00:00:00","reason":"","employee_id":"6","employee_name":"Marina Dimitrijevic","username":"marinica"}]}

    Here is a piece of my code:

    Code:
        
    var getStore = function() {
        	
    		log.debug('Requested team management store');
    		if(store){
    			
    			return store;
    		}	
    		else{
    			
    			store = new Ext.data.JsonStore({
    				
    				url: (controller + '/get_clock_records'),
    				baseParams: 
    				{
    			    	method: 'get'
    			    },
    			    root: 'Clocks',
    			    remoteSort: false,
    				fields: storeFields,
    				pruneModifiedRecords:true,
    				listeners: {
    					
    					load: function() {
    						
    						log.info('Loaded team management store.');
    						log.error('team store');
    						log.error(store);
    					},
    					loadexception: function(This,o, arg,e ) {
    						
    						log.info('Exception on load in team manager ');
    						log.error(e);
    					
    					}
    				}
    
    			});
    			store.load({
    				params: {},
    				callback: function( r, options, success){},
    				add: false
    			});
    		}
    		return store;
    	};
    
    	getStore();
    	
    	var storeFields = [
    		{name: 'id'},
    		{name: 'clock_in'},
    		{name: 'clock_out'},
    		{name: 'seconds'},
    		{name: 'correction'},
    		{name: 'corrected_clock_in'},
    		{name: 'corrected_clock_out'},
    		{name: 'is_corrected'},
    		{name: 'correcter'},
    		{name: 'time_of_correction'},
    		{name: 'reason'},
    		{name: 'employee_id'},
    		{name: 'employee_name'},
    		{name: 'username'}
    	];
    Where I'm wrong?

  2. #2
    Sencha - Services Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,964
    Vote Rating
    11
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default

    Looks like this: "employee_ name" has an extra space in there.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  3. #3
    Ext User
    Join Date
    Mar 2008
    Posts
    11
    Vote Rating
    0
    marinica is on a distinguished road

      0  

    Default

    I don't know where from this extra space appeared,but it is not in my code. So, this is not the solution. It was to good to be true.

  4. #4
    Ext User
    Join Date
    Mar 2008
    Posts
    11
    Vote Rating
    0
    marinica is on a distinguished road

      0  

    Thumbs up

    How silly I was!!!
    I have called getStore() function before I defined storeFields (array with expected json formated fields definition ). When I placed definition for storeFields before getStore definition, everything started to work perfectly. I want to thank henricd for his help.

Thread Participants: 1