Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Getting List To Render

  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    71
    Vote Rating
    0
      0  

    Question Getting List To Render

    I have looked at multiple examples and have tried to follow each but can't get the list to show up in my Media View. The data in the store loads fine from external file. However the list never renders on screen.

    - app.js
    Code:
    Ext.Loader.setConfig({
        enabled:true,
        paths:{
            MonkTouch: 'app'
        }
    });
    Ext.application({
        name: 'MonkTouch',
        autoCreateViewport : true,
        controllers: [
            'Media',
            'Articles'
        ],
        launch : function(){
            Ext.create('MonkTouch.view.Viewport');
        }
    });
    - Viewport.js
    Code:
    Ext.define('MonkTouch.view.Viewport',{
        extend: 'Ext.TabPanel',
        config: {
            fullscreen:true,
            activeItem:0,
            tabBarPosition:'bottom',
            tabBar:{
                layout:{
                    pack:'center',
                    align:'center'
                },
                scrollable:{
                    direction:'horizontal',
                    indecators:false
                }
            },
            items:[
                {
                    title   : 'Media',
                    iconCls : 'action',
                    xtype   : 'medialist'
                },
                {
                    title   : 'Articles',
                    iconCls : 'organize',
                    xtype   : 'articlelist'
                }
            ]
        }
    });
    - media.js //controller
    Code:
     Ext.define("MonkTouch.controller.Media",{
         extend: 'Ext.app.Controller',
         config:{
             fullscreen: true,
             layout:{
                 type:'card',
                 align:'stretch'
             }
         },
         views : ['Media'],
         models : ['Media'],
         stores  : ['Media'],
         init  : function(){
             this.control({
                 'Media' : {
                     itemtap : this.onItemTap,
                     destroy : this.onViewDestroy
                 }
             });
         },
         onItemTap : function(list, index){
             console.log(list);
             console.log(index);
         },
         onViewDestroy : function(){}
     });
    -media.js //view
    Code:
    Ext.define('MonkTouch.view.Media',{
        extend : 'Ext.Panel',
        xtype  : 'medialist',
        defaults: {
            styleHtmlContent: true
        },
        models : ['Media'],
        stores  : ['Media'],
        config: { 
            items:[
                {
                    xtype   : 'list',
                    title   : 'Media List',
                    store   : 'Media',
                    itemTpl : '{title}'
                },
                {
                    xtype   : 'titlebar',
                    title    : 'Media',
                    docked  : 'top',
                    align   : 'center'
                }]
        }
    });
    - media.js //store
    Code:
    Ext.define('MonkTouch.store.Media',{
        extend: 'Ext.data.Store',
        model: 'MonkTouch.model.Media',
        
        autoLoad: true,
        root:{},
        proxy:{
            type:'ajax',
            url:'/lib/mk-modules/media.php',
            reader:{
                type:'json',
                root:'items'
            }
        }
    });
    Last edited by arandlett; 14 Dec 2011 at 10:06 AM. Reason: adding code

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,336
    Vote Rating
    1296
      0  

    Default

    You store does have data in it? If you inspect the DOM, do you see a lot of empty divs?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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
    Jun 2011
    Posts
    71
    Vote Rating
    0
      0  

    Default The Store receives data from the proxy

    I have a local php file which returns the JSON which I confirm is working, but the list never generates after that data is received.

    Yes there is empty divs.

  4. #4
    Sencha User
    Join Date
    Jun 2011
    Posts
    71
    Vote Rating
    0
      0  

    Default There is content just not visible.

    As I inspected it more there is content in the list items however it is not visible.

  5. #5
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,336
    Vote Rating
    1296
      0  

    Default

    Try putting layout : 'fit' in the config Object of your MonkTouch.view.Media class. Your list is wanting a height.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

  6. #6
    Sencha User
    Join Date
    Jun 2011
    Posts
    71
    Vote Rating
    0
      0  

    Default Something Confusing

    Before you posted back the first time I had changed my app.js to this:
    Code:
    Ext.Loader.setConfig({
        enabled:true,
        paths:{
            MonkTouch: 'app'
        }
    });
    Ext.require(['MonkTouch.store.Media']);
    Ext.application({
        name: 'MonkTouch',
        appFolder: 'app',
        autoCreateViewport : true,
        controllers: [
            'Media',
            'Articles'
        ],
        stores : ['Media'],
        models : ['Media'],
        launch : function(){
            Ext.create('MonkTouch.view.Viewport');
        }
    });
    This change allowed the items to render in but not be visible. However if I reverted back to what I originally posted there were no items at all. In addition leaving the configuration like this and adding layout:fit to the MonkTouch.view.Media file did not make the list items visible.

  7. #7
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,336
    Vote Rating
    1296
      0  

    Default

    So when you inspected the DOM you kept going down till you saw a bunch of the same looking divs? And they had text within them that would show the list is getting populated from the store?

    And your MonkTouch.view.Media class looks like this:

    Code:
    Ext.define('MonkTouch.view.Media', {
        extend : 'Ext.Panel',
        xtype  : 'medialist',
    
        models : ['Media'],
        stores  : ['Media'],
    
        config: { 
            layout : 'fit',
            items:[
                {
                    xtype   : 'list',
                    title   : 'Media List',
                    store   : 'Media',
                    itemTpl : '{title}'
                },
                {
                    xtype   : 'titlebar',
                    title    : 'Media',
                    docked  : 'top',
                    align   : 'center'
                }]
        }
    });
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

  8. #8
    Sencha User
    Join Date
    Jun 2011
    Posts
    71
    Vote Rating
    0
      0  

    Default For list to show app.js had to change unsure why...

    I had layout:fit in the wrong place when I added it to the view config object the items showed up. However the list items only showed with my app.js file changed to what I have below not like I had originally posted? Why is that?

    Code:
    Ext.Loader.setConfig({
        enabled:true,
        paths:{
            MonkTouch: 'app'
        }
    });
    
    
    Ext.require(['MonkTouch.store.Media']);
    Ext.application({
        name: 'MonkTouch',
        appFolder: 'app',
        autoCreateViewport : true,
        controllers: [
            'Media',
            'Articles'
        ],
        stores : ['Media'],
        models : ['Media'],
        launch : function(){
            Ext.create('MonkTouch.view.Viewport');
        }
    });

  9. #9
    Sencha User
    Join Date
    Jun 2011
    Posts
    71
    Vote Rating
    0
      0  

    Default Calling Models and Stores in Controller

    From most examples I have seen shouldn't I be able to call
    Code:
    models: ['Media'],
    stores  : ['Media']
    in the controller instead of the app.js file?

    Why would I need the require:['MonkTouch.store.Media'] in the app.js file as well to get the list to work?

  10. #10
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,336
    Vote Rating
    1296
      0  

    Default

    I put mine in the controller not app.js

    I created a simple MVC app using PR3 that you can check out:

    http://www.sencha.com/forum/showthre...le-MVC-example
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

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