PDA

View Full Version : Problem with multiple instances of a grid view with dynamic store, please help.



moozy
5 Jan 2012, 6:54 PM
Hello,

I have chosen to use ext js in my Oxford University project to create dynamic database. I ran in to a problem on which I can't overcome. I spend days trying to figure this out, but no luck. Maybe you will be able to help me.

I have a view called Entity instances (Grid Panel) in which I configure headers, and store dynamically. It works fine, if there is only one instance of it, If I create second (with different parameter), columns are configured correctly, but fields attribute in the new store instance is not being reconfigured. Here is the code :

First the Viewport:



Ext.define('dynCRM.view.Viewport', {
extend: 'Ext.container.Viewport',



layout: 'border',

defaults: {
collapsible: true,
split: true
//bodyStyle: 'padding:15px'
},

items: [
{
title: 'Navigation',
region:'west',
//margins: '5 0 0 0',
//cmargins: '5 5 0 0',
width: 175,
minSize: 100,
maxSize: 250,
xtype: 'EntitiesTable'
},
{
//title: 'Main Content',
id:'homeMain',
collapsible: false,
region:'center',
margins: '0 0 0 0',
bodyStyle: 'padding:0px',
items: [
{
xtype: 'InstancesTable',
eId :'2'
},
{
xtype: 'InstancesTable',
eId :'1'
}

]

}
]




}
);


The instances view:




Ext.define('dynCRM.view.InstancesTable' , {
extend: 'Ext.grid.Panel',
alias: 'widget.InstancesTable',

title: 'Table of Instances',

columns : [],

//requires : ['dynCRM.store.EntityInstances'],

initComponent: function(){

var headers = Ext.create('dynCRM.store.Attributes');
headers.getProxy().extraParams = {'eId' : this.eId};

var columns = new Array();
var storeFields = new Array();

headers.on('load', function(){

headers.each(function(){
columns.push(new Ext.grid.Column({header: this.data.name, dataIndex: this.data.aId, flex: 1}));
storeFields.push(new Ext.data.Field({name: this.data.aId}));

});



var iStore = Ext.create('dynCRM.store.EntityInstances',{fields:storeFields, eId:this.eId});

iStore.load();

this.reconfigure(iStore, columns);

console.log(iStore);
},this

);

headers.load();
console.log('-->InstancesTable');
this.callParent(arguments);


}

});



The store (The one I have problem with)



Ext.define('dynCRM.store.EntityInstances', {
extend : 'Ext.data.Store',

autoLoad: false,

fields:[],

proxy: {
type: 'direct',
api: {
read: qInstancesList.getInstances
}
//extraParams : {eId : this.eId}
},

constructor: function(config){
Ext.apply(this, {fields : config.fields});
this.getProxy().extraParams = {eId : config.eId};

this.callParent(arguments);
}



});


This is what I see, the second view creates the store to load the data, but the store field parameter is not being configured for the second time. Its like I can only create one instance of EntityInstances Store.

Can anyone help me with this please?

slemmon
5 Jan 2012, 8:08 PM
You might check out this thread:
http://www.sencha.com/forum/showthread.php?170966-Grid-in-tab-in-window-fails-on-second-open&highlight=type%3A