Results 1 to 2 of 2

Thread: Store (model) doesn't load associated data when loading?

  1. #1
    Sencha User
    Join Date
    Jul 2018
    Posts
    3

    Default Store (model) doesn't load associated data when loading?

    Well I must be understanding something wrong, but the store I currently build does not seem to load associated data at all, in either way the "main" model is the "event", an event belongs to an organization, and it has several "sections". The sections are loaded as nested data when calling the events, while the events itself are loaded separately from the organization store.

    The models:

    Code:
    Ext.define('AllSports.model.Event', {    extend: 'AllSports.model.Base',
        identifier: 'sequential',
    
    
        fields: [{
            name: 'id'
        }, {
            name: 'name'
        }, {
            name: 'organization',
            reference: {
                type: 'AllSports.model.Organization',
                association: 'EventOrganization',
                role: 'organization',
                getterName: 'getOrganization',
                setterName: 'setOrganization',
                inverse: 'users',
            },
        }],
    });
    
    
    Ext.define('AllSports.model.Section', {
        extend: 'AllSports.model.Base',
    
    
        fields: [{
            name: 'id',
        }, {
            name: 'name'
        }, {
            name: 'event',
            reference: {
                type: 'AllSports.model.Event',
                association: 'SectionEvent',
                role: 'event',
                getterName: 'getEvent',
                setterName: 'setEvent',
                inverse: 'sections',
            },
        }],
    });
    The store for the events is also quite simple:


    Code:
    Ext.define('AllSports.store.Event', {
        extend: 'Ext.data.Store',
        storeId: 'Events',
        alias: 'store.events',
        autoLoad: true,
        model: 'AllSports.model.Event',
        data: {
            items: [{
                "sections": [{
                    "id": 1,
                    "name": "A",
                    "event": 1
                },{
                    "id": 2,
                    "name": "abcdef",
                    "event": 1
                },{
                    "id": 3,
                    "name": "abcdefghi",
                    "event": 1
                },{
                    "id": 4,
                    "name": "abcdefghi1",
                    "event": 1
                }],
                "id": 1,
                "name": "event",
                "organization": 10
            },{
                "sections": [],
                "id": 8,
                "name": "future_event2",
                "organization": 10
            }]
        },
        proxy: {
            type: 'memory',
            reader: {
                type: 'json',
                rootProperty: 'items'
            }
        }
    
    });


    now if I use this code in some object (say mainController), and add an event to test the loaded data, I notice things aren't loaded quite correctly.

    Code:
    const org_store = Ext.getStore('FilteredOrganizations');
    const event_store = Ext.getStore('Events');
    if (event_store.isLoaded()) {
    	const ev = event_store.findRecord('name', 'org');
    	//const v2 = ev.getOrganization();
    	//const v3 = ev.getSections();
    	const org = org_store.findRecord('id', 10);
    	debugger;
    })
    Uncommenting either of the two commented lines gives an error, and verification shows that both getOrganization as well as getSections are undefined. So what is happening, why is the store not loaded correctly?

  2. #2
    Sencha - Forum Administrator
    Join Date
    Sep 2017
    Posts
    1,005
    Answers
    5

    Default

    Hi there- thank you for your question. I will forward this over to the support team to look into. They will reach out at their earliest convenience. Thank you so much for your patience.

    Michele

Similar Threads

  1. Associated data is not loading after model load
    By SemihG. in forum Ext JS 6.x Bugs
    Replies: 2
    Last Post: 19 Oct 2015, 11:07 AM
  2. Replies: 18
    Last Post: 3 Feb 2015, 5:32 PM
  3. [CLOSED] Ext.data.Model.load() doesn't work due to recordCreator
    By romainpicxi in forum Ext 5: Bugs
    Replies: 4
    Last Post: 5 Jun 2014, 12:38 AM
  4. Loading data via a Model.. model has no method load()
    By rhomb in forum Sencha Touch 2.x: Q&A
    Replies: 10
    Last Post: 12 Sep 2013, 11:40 AM
  5. Creating a copy of a Store/Model doesn't load the data
    By softwarezman in forum Ext: Discussion
    Replies: 1
    Last Post: 30 Jul 2011, 5:52 AM

Posting Permissions

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