1. #1
    Sencha User
    Join Date
    Dec 2011
    Location
    White Rock, BC Canada
    Posts
    161
    Answers
    11
    Vote Rating
    0
    WagsMax is on a distinguished road

      0  

    Default Answered: Trouble with Instances of a grid panel with their own instance of a store

    Answered: Trouble with Instances of a grid panel with their own instance of a store


    I can't seem to figure out how to do this... what I want is multiple instances of a grid panel, that should create their own instance of a store to hold that panel's data. With my code below, the grid always shows up empty. Can anyone see the problem?


    My store:
    Code:
    Ext.define('MyApp.store.Contacts', {
        extend: 'Ext.data.Store',
    	storeId: 'contactsStore',
        alias: 'store.contacts',
    
    
    	autoLoad: true,
    	model: 'MyApp.model.Contacts',
    	proxy: {
    		type: 'memory'
    	}
    });

    My model (removed some fields for brevity):
    Code:
    Ext.define('MyApp.model.Contacts', {
        extend: 'Ext.data.Model',
        alias: 'model.contacts',
    	fields: [
    		{
    			name: 'contact_id',
    			type: 'string',
    			defaultValue: ''
    		},
    		{
    			name: 'contact_number',
    			type: 'string',
    			defaultValue: ''
    		},
    		{
    			name: 'address_name',
    			type: 'string',
    			defaultValue: ''
    		}
    
    	]
    });

    My grid panel:
    Code:
    Ext.define('MyApp.view.CaseContacts', {
        extend: 'Ext.grid.Panel',
        alias: 'widget.casecontacts',
        itemId: 'casecontacts',
        
    	frame: false,
    	title: 'Contacts',
    	bodyPadding: 5,
    	closable: true,
    	autoDestroy: true,
        autoScroll: true,
    	
        // custom configs
        config: {
    		case_record: null
    	},
        
        features: [{
            ftype: 'filters',
            encode: true,
            local: true
        }],
    
    
        columns: [
            { text: 'Name', dataIndex: 'address_name', filterable: true, filter: { type: 'string'} },
            { text: 'Address', dataIndex: 'address', filterable: true, filter: { type: 'string'} },
            { text: 'Main Phone', dataIndex: 'phone_main', filterable: true, filter: { type: 'string'} },
            { text: 'Work Phone', dataIndex: 'phone_work', filterable: true, filter: { type: 'string'} },
            { text: 'Mobile Phone', dataIndex: 'phone_mobile', filterable: true, filter: { type: 'string'} },
            { text: 'Email', dataIndex: 'email', filterable: true, filter: { type: 'string'} },
            { text: 'Notes', dataIndex: 'notes', filterable: true, filter: { type: 'string'} }
        ]
    	
    });

    The part of the controller code that creates/loads the store and displays the grid panel. The console.log() does show records being added to the store, so I know the store has data. I assign the store config with store: contactsStore, but no data shows up.
    Code:
                    // load the Contacts store from xml data
    				var contactsStore = Ext.create('MyApp.store.Contacts');
                    contactsStore.removeAll();
                    nodes = xpath.selectNodes("//*/contacts/*");
                   	for (i = 0; i < nodes.length; i++) {
                   		var item = Ext.create('MyApp.model.Contacts');
                   		// disassemble
    					xpathtemp.loadXML(nodes[i].me.xml);
    					nodestemp = xpathtemp.selectNodes("//contact/*");
    					for (j = 0; j < nodestemp.length; j++) {
    						try { item.set(nodestemp[j].nodeName, nodestemp[j].text); } catch (e) {}
    					}
                        contactsStore.add(item);
                   	}
                   	console.log(contactsStore.getCount() + " records in Contacts store");
                   	// the above statement shows records in the Contacts store
                    
    				// CaseContacts
    				var casecontactsPanel = Ext.create('MyApp.view.CaseContacts', {
    					xtype: 'casecontacts',
    					itemId: 'casecontacts' + record.get('case_id'),
    					tabConfig: {
    						tooltip: 'Contacts'
    					},
    					store: contactsStore,
    					case_record: record
    				});
    		
    				// create the master tab panel
    				var thePanel = Ext.create('MyApp.view.CaseTabs', {
    					xtype: 'casetabs',
    					itemId: 'casetabs' + record.get('case_id'),
    					title: record.get('case_number'),
    					case_record: record
    				});
    				
    				// add tab(s)
    				thePanel.add(casecontactsPanel);
    				thePanel.setActiveTab(thePanel.items.items.length - 1);
    
    
    				// display the master tab panel
    				Ext.getCmp('maintabs').add(thePanel);
    				Ext.getCmp('maintabs').setActiveTab(Ext.getCmp('maintabs').items.items.length - 1);

  2. Try to set autoLoad to false. Setting autoLoad to true will cause store loading data from contactsStore.data which is null. Because this loading is deferred so it will happen after you've created and added data to it so it will clear all data you have added to contactsStore.
    Code:
        Ext.define('MyApp.store.Contacts', {
            extend: 'Ext.data.Store',
            storeId: 'contactsStore',
            alias: 'store.contacts',
            autoLoad: false,
            model: 'MyApp.model.Contacts',
            proxy: {
                type: 'memory'
            },
            // debug
            listeners: {
                load: function(){
                    console.log('store loaded');
                }
            }
            // debug
        });

  3. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Have you checked to make sure each record in store has correct data?

  4. #3
    Sencha User
    Join Date
    Dec 2011
    Location
    White Rock, BC Canada
    Posts
    161
    Answers
    11
    Vote Rating
    0
    WagsMax is on a distinguished road

      0  

    Default


    Yes, the store has valid data in it. I am baffled.

  5. #4
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Try to set autoLoad to false. Setting autoLoad to true will cause store loading data from contactsStore.data which is null. Because this loading is deferred so it will happen after you've created and added data to it so it will clear all data you have added to contactsStore.
    Code:
        Ext.define('MyApp.store.Contacts', {
            extend: 'Ext.data.Store',
            storeId: 'contactsStore',
            alias: 'store.contacts',
            autoLoad: false,
            model: 'MyApp.model.Contacts',
            proxy: {
                type: 'memory'
            },
            // debug
            listeners: {
                load: function(){
                    console.log('store loaded');
                }
            }
            // debug
        });

  6. #5
    Sencha User
    Join Date
    Dec 2011
    Location
    White Rock, BC Canada
    Posts
    161
    Answers
    11
    Vote Rating
    0
    WagsMax is on a distinguished road

      0  

    Default


    Setting autoload to false did it!!! Thank you.
    Now I just have one question... little red triangles appear in the upper left corner of every field, and I am assuming that ext thinks these fields are all dirty... how can I get rid of these triangles after first loading the store?

  7. #6
    Sencha User
    Join Date
    Dec 2011
    Location
    White Rock, BC Canada
    Posts
    161
    Answers
    11
    Vote Rating
    0
    WagsMax is on a distinguished road

      0  

    Default


    Answer to little red triangles... I forgot to add a contactsStore.sync() after loading the store. All better now

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi