PDA

View Full Version : Load same store in a grid and in a combo



rafaelrp
23 Apr 2013, 5:36 PM
Hello!
I have to load a store that is already in use into a combo, but when i select a value in the combo the store reload in the grid with a filter with the value i clicked.


I have to create a store for the grid and a store to the combo or i can use the same store?
I don't want to the grid reloads.

combo:


{
xtype: 'combo',
name: 'cliente',
store: 'Clientes',
queryMode: 'local',
fieldLabel: 'Cliente',
valueField: 'clienteId',
displayField: 'nome',
allowBlank: false
},



store:


Ext.define('Pagamator.store.Clientes', {
extend: 'Ext.data.Store',
model: 'Pagamator.model.Clientes',
autoLoad: true,

proxy: {
type: 'ajax',
api: {
read: 'data/clientesList.php',
update: 'data/clientesUpdate.php',
create: 'data/clientesCreate.php',
destroy: 'data/clientesDelete.php'
},
reader: {
type: 'json',
//root: 'data',
successProperty: 'success'
},
writer: {
type: 'json',
root: 'data',
encode: true
}
}
});

model:


Ext.define('Pagamator.model.Clientes', {
extend: 'Ext.data.Model',
fields: [
'clienteId',
'nome',
'sexo',
'endereco',
'cpf',
'rg',
'bairro',
'cidade',
'estado',
'cep',
'cidadeEstado',
'dataNascimento',
'foneCelular',
'dataCadastro',
'formaPagamento',
'formaPagamentoId',
'quantidadeSemanal',
'quantidadeSemanalId',
'email',
'observacao'
]
});





Thanks!

slemmon
25 Apr 2013, 10:38 AM
Sounds like you're not wanting to share a store instance between two components, but rather a store type shared between the components.

In your store definition you can give it an alias like alias: 'store.mystore'
and then in your components you can do:
store: { type: 'mystore' }

That way filtering grid store won't affect the combo store.