Results 1 to 4 of 4

Thread: Data loading but not put in store.

  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    74
    Answers
    1
    Vote Rating
    2
      0  

    Default Answered: Data loading but not put in store.

    I am trying to load data into a list based on dynamically added parameters. In the console I can see that the data is being fetched, but looking at the store when everyting as rendered, nothing is put in the store, and (of course) nothing is put on the list.

    The data are being loaded via the activate event on the view, the view is in a carousel.

    I am Sencha Touch 2.0 beta 1

    Store
    Code:
    Ext.define('MyApp.store.Participants', {
        extend: 'Ext.data.Store',
         config: {
            model: 'MyApp.model.Participant',
             proxy: {
                type: 'ajax',
                url: 'xhr/xhrStore.asp?cmd=getParticipants',
                 reader: {
                    type: 'json',
                    rootProperty: 'items'
                }
            }
        }
    });
    Model:
    Code:
    Ext.define('MyApp.model.Participant', {
        extend: 'Ext.data.Model',
         config: {
            fields: [
                { name: 'ID', type: 'int', hidden: true },
                { title: 'Billede', name: 'pic', type: 'string' },
                { title: 'Fornavn', name: 'firstname', type: 'string' },
                { title: 'Efternavn', name: 'lastname', type: 'string' }
            ]
        }
    });
    Method loading the data:
    Code:
     onLoadParticipantsRequest: function (self, newActiveItem, oldActiveItem, eOpts) {
            var index = index = window.location.hash.substring(1).split('/'),
                participantsView = this.getParticipantsView(),
                store = participantsView.getStore();
             store.load({
                callback: this.onParticipantsLoaded,
                params: {
                    sel: index[0],
                    afd: index[1],
                    afsnit: index[2],
                    tdate: index[3]
                }
            });
    },
    The view with the list:
    Code:
    Ext.define('MyApp.view.partial.Participants', {
        extend: 'Ext.dataview.List',
        xtype: 'participants',
         config: {
            flex: 25,
             clearSelectionOnDeactivate: true,
            cls: 'participantslist',
            id: 'participantslist',
            styleHtmlContent: true,
            store: 'Participants',
            flex: 25,
            itemSelector: 'div.participantitem',
            itemTpl: ['<div class="participantitem">',
                    '<img src="{pic}" alt="" />',
                    '<span class="field">{firstname} {lastname}</span>',
                    '</div>'].join(''),
             items: [{
                xtype: 'toolbar',
                docked: 'bottom',
                items: [{
                    text: 'Tilfj',
                    xtype: 'button',
                    id: 'add_participant_button'
                }]
            }]
        }
     });
    The data I see loaded but not put in the store afterwards:
    Code:
     {
        "rows": [
            {"ID": 1686,"pic": "\u002Fcommon\u002Fimages\u002Ffemale.gif","firstname": "asd","lastname": "asd"},
            {"ID": 1913,"pic": "\u002Fcommon\u002Fimages\u002Fmale.gif","firstname": "asd","lastname": "asd"},
            {"ID": 2307,"pic": "\u002Fcommon\u002Fimages\u002Ffemale.gif","firstname": "asd","lastname": "asd"},
            {"ID": 2214,"pic": "\u002Fcommon\u002Fimages\u002Ffemale.gif","firstname": "asd","lastname": " asd"},
            {"ID": 1684,"pic": "\u002Ffiles\u002Fassets\u002Fplus-bolig.dk\asd.gif","firstname": "asd","lastname": "asd"},
            {"ID": 2236,"pic": "\u002Fcommon\u002Fimages\u002Ffemale.gif","firstname": "asd ","lastname": "asd"},
            {"ID": 1740,"pic": "\u002Fcommon\u002Fimages\u002Fmale.gif","firstname": "asd","lastname": "asd"},
            {"ID": 1703,"pic": "\u002Fcommon\u002Fimages\u002Ffemale.gif","firstname": "asd","lastname": "asd"},
            {"ID": 1704,"pic": "\u002Fcommon\u002Fimages\u002Fmale.gif","firstname": "asd","lastname": "asd"},
            {"ID": 2275,"pic": "\u002Ffiles\u002Fassets\u002Fplus-bolig.dk\asd%C3%asd.jpg","firstname": "asd","lastname": "asd"},
            {"ID": 2274,"pic": "\u002Ffiles\u002Fassets\u002Fplus-bolig.dk\asd%20p.jpg","firstname": "asd","lastname": "asd"}
        ]
     }

  2. The root in your JSON is 'rows' but in your store you have 'items' in the rootProperty config.

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3932
    Vote Rating
    1272
      0  

    Default

    The root in your JSON is 'rows' but in your store you have 'items' in the rootProperty config.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Jan 2012
    Posts
    74
    Answers
    1
    Vote Rating
    2
      0  

    Default

    Lol, one of these days my embarassment will overcome me. Thank you!

  5. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3932
    Vote Rating
    1272
      0  

    Default

    Quote Originally Posted by msweltzdk View Post
    Lol, one of these days my embarassment will overcome me. Thank you!
    Everyone has these moments and will always have them We are human!
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •