PDA

View Full Version : Ext.create on store returning error



wallynm
17 Jan 2012, 10:26 PM
Hello guys, i'm needing to use Ext.create at one store defined on the system...
The problem it's because when i try to do it, firefox and crhome return errors:

Crhome:
c is not a constructor
...instantiators[length] = new Function('c', 'a', 'return new c('+args.join(',')+'...

Firefox:
Uncaught TypeError: object is not a function


Well, i have any idea why it is happening...
Here it's defined codes, creation and etc...



Ext.define('gconnect.view.Financeiro.Lancamento.Sidebar', { extend: 'Ext.grid.Panel',
id:'SidebarLancamento',
alias: 'widget.SidebarLancamento',
store: Ext.create('gconnect.store.Financeiro.ListaContas.ListaContas'),


layout:'fit',
border:false,
features: [
Ext.create('Ext.grid.feature.Grouping', {
groupHeaderTpl: '{name} ({rows.length})',
startCollapsed: true
})
],
columns:[
{header: 'Conta', dataIndex: 'nome', flex: 1},
{header: 'Saldo Atual', dataIndex: 'saldoatual', flex: 1}
]
});

My problem it's with this line:

Ext.create('gconnect.store.Financeiro.ListaContas.ListaContas')


My store definition:

Ext.define('gconnect.store.Financeiro.ListaContas.ListaContas', { extend: 'Ext.helper.Abstract.DefaultStore',
model: 'gconnect.model.Financeiro.ListaContas.ListaContas',


idProperty: 'codlistaconta',
urlRead: baseurl+'financeiro/lista_contas/listar',
urlSave: baseurl+'financeiro/lista_contas/salvar',
urlDelete: baseurl+'financeiro/lista_contas/deletar'
});

My Extended store:


Ext.define('Ext.helper.Abstract.DefaultStore', {
extend: 'Ext.data.Store',
//autoLoad: true,
autoSync: true,
pageSize: 20,

idProperty: undefined,
urlRead: undefined,
urlSave: undefined,
urlDelete: undefined,

constructor: function(options){
Ext.apply(this,options || {});

this.proxy = {
method: 'POST',
type: 'ajax',
url: this.urlRead,
actionMethods: { read: 'POST' },
reader: {
idProperty: this.idProperty,
type: 'json',
root: 'data',
totalProperty: 'total',
successProperty: 'success'
}
}


this.callParent(arguments);
}
})

ero
17 Jan 2012, 11:57 PM
I normally see that error when I forget to include a class within my controller. Have you added the store and model to your controller?

Also, I'm not sure that you can use Ext.create within your definition if it's not called from within another method (e.g. initComponent() )

You may need to try as follows:



initComponent: function() {

var store = Ext.create('gconnect.store.Financeiro.ListaContas.ListaContas');

Ext.apply(this, {
store: store
});

this.callParent(arguments);

}

wallynm
18 Jan 2012, 12:11 AM
I normally see that error when I forget to include a class within my controller. Have you added the store and model to your controller?

Also, I'm not sure that you can use Ext.create within your definition if it's not called from within another method (e.g. initComponent() )

You may need to try as follows:



initComponent: function() {

var store = Ext.create('gconnect.store.Financeiro.ListaContas.ListaContas');

Ext.apply(this, {
store: store
});

this.callParent(arguments);

}



It's funny that i didn't thougth this... I use the initComponent on every place on the system, and didn't tryed to set the store with he... As you said, i can't assign directly
Ext.create('gconnect.store.Financeiro.ListaContas.ListaContas');

to the store, but as you posted, using the initComponent everything it's fine... Thanks by the help!!!