1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    3
    Vote Rating
    0
    robi.ilham is on a distinguished road

      0  

    Default Answered: cannot load data from store

    Answered: cannot load data from store


    i want to store data from a server that i get using jsonp request. but the problem when i tried to load the data using dataview there are no data in the view

    this is the store and model:
    Code:
    Ext.define('Moapp.model.News', {    extend: 'Ext.data.Model',
        
        config: {
            fields: [
                {name: 'id', type: 'auto'},
                {name: 'title', type: 'auto'},
                {name: 'message', type: 'auto'},
                {name: 'large_images', type: 'auto'}
            ]
        }
    });
    streamStore = new Ext.data.Store({
        model: 'Moapp.model.News',
        proxy: {
                type: "localstorage",
                id: "newsStream",
                reader: {
                type: 'json',
                }            
          },
        autoLoad: true
    });
    this is the request:
    Code:
    Ext.data.JsonP.request({            url:'http://lintas.me/chrome/channel_news/fun/',
                callbackKey:'callback',
                success:function (result) {
                    item=result['items'];
                    console.log(item);
                   streamStore.setData(item);
        
                    
                    }
                });
    and this is the view
    Code:
    Ext.define('Moapp.view.ChannelStreamList',{    extend:'Ext.dataview.DataView',
        xtype:'channelstreamlist',
        
        config:{
            flex:1,
            scrollable:true,
            //store:streamStore,
            itemSelector: "div.stream_item",
            tpl: [
                    '<div id="stream2">',
                         '<tpl for=".">',
                            '<div class="stream_item" id="{id}" ><img src="{large_images}" /><div class="stream-title">{title}</div></div>',
                        '</tpl>',
                        '<div class="clear"></div>',
                    '</div>',
                
            ],
        }
    });
    please help.
    thank you

  2. You should use itemTpl in your dataview, not tpl.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,650
    Vote Rating
    899
    Answers
    3575
    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 itemTpl in your dataview, not tpl.
    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.

Thread Participants: 1