1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    7
    Vote Rating
    0
    whatadewitt is on a distinguished road

      0  

    Default Stuck with List/Store/Model Problem (n00b)

    Stuck with List/Store/Model Problem (n00b)


    Hi everyone,

    I'm new to Sencha Touch and I am working on learning it and building a simple app, however I have hit a snag and as much as I search the web, I cannot find my answer...

    I have a simple model...

    Code:
    Ext.regModel('MyModel', {
        fields: [
            'foo', 'bar', 'funk', 'time']
    });
    I then have a list I am trying to populate with some data from a webservice...

    Code:
    var store = new Ext.data.Store({
     			model: 'MyModel',
        		proxy: {
    				type: 'ajax',
    				url : 'http://localhost:8888/data/data.php',
    				reader: {
    					type: 'json',
    					root: 'fundata'
                 	},
    			},
    			autoLoad: true
    		});
    Just after this, I create a list to display this data...

    Code:
    var list = new Ext.List({
    			fullscreen: true,
            	itemTpl : '<div>{foo} ({bar})</div>',
            	store: store
        	});
    		list.show();
    I am getting a list with the correct number of items in it, however, the "foo" and "bar" are both empty... I don't know whether the problem is in the store or the list... I have set up a .load instead of using autoload and I log the results to the console, however, I can't tell if the data is correct or not... Can anyone help me figure out what's going on here... any help would be appreciated!

    Thanks!

    --d

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Vote Rating
    847
    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


    Have you check dev tools in Chrome or Safari on the desktop?

    Did you browse to this List in the browser going to localhost:8888? Normally you just go to localhost so if you are go on a different port, that is treated as a separate domain which will not work with Ajax.
    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.

  3. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    7
    Vote Rating
    0
    whatadewitt is on a distinguished road

      0  

    Default


    Hi Mitchell!

    Yes, I know the data is coming back, but I am not sure that it's populating the "store" properly. If I set up a listener on the load function and log the results I am seeing an array with the right number of elements, but they are all "c" objects? (At least it says "c"next to the arrow icon to drop down for more details).

    I can browse through this object and see that the data is in there, but I can't see it in the way I had specified in the store... I can only see the normal JSON pieces...but I cannot seem to figure out how to get that data to populate my list...

    Thanks, hoping you can keep helping me

    --d

    EDIT: ... aaaaand just like that I figure it out! When it wasn't working I made some changes to my store but not my template... ugh!! This is a great library, I am enjoying the learning process no matter the hiccups I encounter! Thanks again!

Thread Participants: 1