Results 1 to 5 of 5

Thread: store.getRoot is not a function, Can't use a reference to a store

  1. #1
    Sencha User
    Join Date
    May 2015
    Posts
    13

    Default Answered: store.getRoot is not a function, Can't use a reference to a store

    Hello everyone, I have created a store in app/store/, the store is being initiated just fine, I've tried to access it in the debugger Ext.data.StoreManager.get('MyStore') returns the store and all data is there.


    I added the store in my app.js


    Code:
    stores: ['MyStore'],

    And in the view I've added it to the requires array, here is the store definition code:


    Code:
    Ext.define('MyTest.store.MyStore', {
        extend: "Ext.data.Store",
        type: "tree",
        config: {
            autoLoad: true,
            storeId: 'MyStore'
        },
        fields: ['title', 'link', 'author', 'contentSnippet', 'content',
        {
            name: 'leaf',
            defaultValue: true
        }],
        root: {
            leaf: false
        },
        proxy: {
            type: 'jsonp',
            url: 'http://localhost/mobile_apps/stores/MyTest/test.json',
            reader: {
                type: 'json',
                rootProperty: 'responseData.feed.entries'
            }
        }
    });
    And here is the view code:


    Code:
    Ext.define('MyTest.view.SearchPanel', {
        extend: 'Ext.Panel',
        xtype: 'searchpanel',
        requires: ['MyTest.store.MyStore'],
        config: {
            layout: 'fit',
            items: [
            {
                xtype: 'fieldset',
                layout: {
                    layout: 'vbox',
                    pack: 'center'
                },
                items: [{
                    xtype: 'searchfield',
                    placeHolder: 'Enter keyword ...'
                }]
            },
            {
                xtype: 'nestedlist',
                displayField: 'title',
                store: 'MyStore',
                detailCard: {
                    xtype: 'panel',
                    scrollable: true,
                    styleHtmlContent: true
                },
                listeners: {
                    itemtap: function(nestedList, list, index, element, post) {
                        this.getDetailCard().setHtml(post.get('content'));
                    }
                }
            }]
        }
    });

    I am getting this error: "Uncaught TypeError: newStore.getRoot is not a function"
    And "Uncaught TypeError: store.getRoot is not a function"


    If I write the store code inside the view, it works just fine, but I thought I'd rather separate them as this sounds like the right thing to do


    So what am I doing wrong here, how do I properly define a store so I can use it in nestedlist in other views?


    And another question is, the nestedlist was not rendering until I changed the layout to 'fit', but once I did that the searchfield was not rendered, so is it possible to have the fieldset and the nestedlist on the same panel as I do, how do I get the searchfield in my example above to render right above the nestedlist?

    Thanks

  2. NestedList expects a TreeStore not a Store.

    http://docs.sencha.com/touch/2.4/2.4...data.TreeStore

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449
    Answers
    3997

    Default

    NestedList expects a TreeStore not a Store.

    http://docs.sencha.com/touch/2.4/2.4...data.TreeStore
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    May 2015
    Posts
    13

    Default

    Thank you, I did not see that. What about the other part of the question? The fieldset is not rendering when the layout is set to 'fit' and if I remove that bit, the nestedlist will then not render, how do I get them both to render on the same panelThanks

  5. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449
    Answers
    3997

    Default

    fit layout will ONLY fit a single item, you're trying to fit two items.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  6. #5
    Sencha User
    Join Date
    May 2015
    Posts
    13

    Default

    I see, thank you very much for the clarification, I will try to figure out a way to display the nestedlist on a different item then, without setting the layout to fit the nestedlist will not render.

Similar Threads

  1. Replies: 9
    Last Post: 17 Apr 2014, 12:42 PM
  2. Replies: 4
    Last Post: 23 Jan 2014, 2:54 AM
  3. Replies: 1
    Last Post: 12 Apr 2013, 9:07 AM
  4. Reference instance function/variable inside a store refresh event
    By sephyroth69 in forum Sencha Touch 2.x: Q&A
    Replies: 4
    Last Post: 9 Apr 2012, 5:01 AM
  5. a string reference vs. object reference passed to a function
    By dolittle in forum Community Discussion
    Replies: 2
    Last Post: 1 Nov 2008, 8:45 AM

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
  •