Extjs 4.2.1 - storemanager.lookup return undefined

I have a really simple program where I try to connect a store to Ext.panel.Grid. I can't seem to get Ext.data.StoreManager.lookup () in a call to Main.js to return anything other than "undefined". Ext.create ('LeaveRequestGrid.store.LeaveRequestStore') seems to work (with some warnings), but I want to know how to do it right.

LeaveRequestStore.js:

Ext.define('LeaveRequestGrid.store.LeaveRequestStore', {
    extend: 'Ext.data.Store',
    storeId: 'leaveRequestStore',
    autoLoad: true,
    fields: [
        'dateCreated',
        'startDate',
        'endDate',
        'leaveType',
        'totalHours',
        'approver',
        'status'
    ],
    data: {
        'leaveRequest' : [
            {   
                'dateCreated': '12/01/2013' ,
                'startDate' : '01/01/2014',
                'endDate' : '01/02/2014' ,
                'leaveType' : 'Paid Admin Leave' ,
                'totalHours' : 16 ,
                'approver' : 'John Smith' ,
                'status' : 'Pending' 
            },
            {   
                'dateCreated': '01/01/2014' ,
                'startDate' : '02/01/2014',
                'endDate' : '02/02/2014' ,
                'leaveType' : 'Vacation' ,
                'totalHours' : 16 ,
                'approver' : 'John Smith' ,
                'status' : 'Pending' 
            },
            {   
                'dateCreated': '02/01/2013' ,
                'startDate' : '03/01/2014',
                'endDate' : '03/02/2014' ,
                'leaveType' : 'Paid Time Off' ,
                'totalHours' : 16 ,
                'approver' : 'John Smith' ,
                'status' : 'Pending' 
            }
        ]
    },
    proxy: {
        type: 'memory',

        reader: {
            type: 'json',
            root: 'leaveRequest'
        }
    }
})

Main.js:

Ext.define('LeaveRequestGrid.view.Main', {
    extend: 'Ext.container.Container',
    requires:[
        'Ext.grid.Panel',
        'LeaveRequestGrid.store.LeaveRequestStore'
    ],

    xtype: 'app-main',

    layout: {
        type: 'fit'
    },

    items: [
        {
            xtype: 'grid',
            title: '<div style="text-align:center">Leave Requests</div>',
            //store: Ext.create('LeaveRequestGrid.store.LeaveRequestStore'),
            store: Ext.data.StoreManager.lookup('leaveRequestStore'),
            columns: [
                {text: 'Date Created', dataIndex: 'dateCreated', flex: 1},
                {text: 'Start Date', dataIndex: 'startDate', flex: 1},
                {text: 'End Date', dataIndex: 'endDate', flex: 1},
                {text: 'Leave Type', dataIndex: 'leaveType', flex: 1},
                {text: 'Total Hours', dataIndex: 'totalHours', flex: 1},
                {text: 'Approver', dataIndex: 'approver', flex: 1},
                {text: 'Status', dataIndex: 'status', flex: 1}
            ]
        }
    ]
});
+4
source share
1 answer

I understood that.

stores: ['LeaveRequestStore'] Application.js. Main.js ( - , gridpanel), store: 'LeaveRequestStore'. . Ext.getStore('LeaveRequestStore') Ext.data.StoreManager.lookup('LeaveRequestStore'). store.

+5

All Articles