1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    12
    Vote Rating
    0
    Answers
    1
    Saemy is on a distinguished road

      0  

    Default Answered: Store - JSON - Data not loaded

    Answered: Store - JSON - Data not loaded


    Hi

    I hava a problem with JSON und Store. I want to display simple JSON-Data in a DataView from a Store.

    When i analyse with debugger i ses, that tha "raw"-data in Store "userStore" is filled with with 12 news-objects. but the data it self is empty...

    I can't find any solution so far...
    Here is my code:

    1. my Model:
    Code:
    Ext.define('zhaw.model.News', {
        extend: 'Ext.data.Model',
        config: {
    	    fields: [
    	             {name: 'id', type: 'int'},
    	             {name: 'title', type: 'string'},
    	             {name: 'content', type: 'string'},
    	             {name: 'date', type: 'string'}
    		]
        }
    });
    
    2. app.js
    Code:
    Ext.Loader.setConfig({
        enabled: true
    });
    
    
    var userStore;
    
    
    Ext.application({
        name: 'zhaw',
        
     //   profiles: ['Phone', 'Tablet'],
        views: ['Viewport', 'Hello'],
        models: ['News'],
    
    
        //controllers: ['Main'],
      
        //3# Application Launch 
        launch: function() {
        	console.debug('Anwendungsstart');
        	
        	
        	  userStore = Ext.create('Ext.data.Store', {
        		  	//requires: 'zhaw.model.News',
        		    autoLoad: false,
        		  	model: 'zhaw.model.News',
        	        
        	        storeId: 'userS',
        	        proxy: {
        	            type: 'ajax',
        	           // url: 'js/app/model/data/news.json',
        	            url: 'app/jsonNews',
        	            reader: {
        	                type: 'json',
        	                root: 'news',
        	                successProperty: 'success'
        	              
        	            }
        	        },
        	        listeners: {
    	    	        load: function( me, records,  successful, operation,  eOpts ) {
    	    	      
    	    	        	console.debug('Load Called');
    	    	        }
        	        }
        	  		
        	    });
        	  
        	var touchTeam = Ext.create('Ext.DataView', {
        	    fullscreen: true,
    
    
        	    store: 'userS',
    
    
        	    itemTpl: 'is {id} years {content} old'
        	});
        	
        	userStore.load();
        	console.debug('Ende');
        },
    3. my Json Data:
    Code:
    {"news": [{"id":1,"content":"Test","title":"Testr","date":"Feb 29, 2012 3:45:06 PM"},{"id":2,"content":"Test","title":"Testr","date":"Feb 29, 2012 3:45:58 PM"},{"id":3,"content":"Test","title":"Testr","date":"Feb 29, 2012 3:46:12 PM"},{"id":4,"content":"Test","title":"Test2","date":"Feb 29, 2012 3:46:16 PM"},{"id":5,"content":"Test","title":"Test2","date":"Feb 29, 2012 3:46:48 PM"},{"id":6,"content":"Test","title":"Test3","date":"Feb 29, 2012 3:46:52 PM"},{"id":7,"content":"Test","title":"Testr","date":"Feb 29, 2012 3:48:23 PM"},{"id":8,"content":"Test","title":"Testr","date":"Feb 29, 2012 4:08:25 PM"},{"id":9,"content":"Test","title":"Testr34","date":"Feb 29, 2012 4:41:23 PM"},{"id":10,"content":"Test","title":"Testr3436","date":"Feb 29, 2012 4:41:42 PM"},{"id":11,"content":"Test","title":"Test12332143","date":"Mar 1, 2012 2:44:02 PM"},{"id":12,"content":"Test","title":"haosdif","date":"Mar 1, 2012 2:48:32 PM"}]}
    kindest regards Sam

  2. The problem is the rootProperty... i called it root (like in Sencha Touch 1) instead of rootProperty...



    kindest Sam

  3. #2
    Sencha User
    Join Date
    Aug 2011
    Posts
    12
    Vote Rating
    0
    Answers
    1
    Saemy is on a distinguished road

      0  

    Default Found the problem: rootProperty

    Found the problem: rootProperty


    The problem is the rootProperty... i called it root (like in Sencha Touch 1) instead of rootProperty...



    kindest Sam

Tags for this Thread