PDA

View Full Version : Combo Serach in All Nodes of Array



alberto_matos
4 Oct 2013, 12:44 PM
Hello Friend, I am doing a combo with search and accurate search on all nodes of my array. Someone, please, could tell me how to do this?

<code>
================ Example my menu.json ===============

{
"menu": [
{
"text": "Cadastros",
"expanded": true,
"menu": [
{
"text": "Cursos",
"expanded": true,
"menu": [
{
"text": "Subcursos",
"leaf": true,
"xtypeClass": "aidfconfiguracao"
},
{
"text": "Aulas",
"leaf": true,
"xtypeClass": "aidfconfiguracao"
},
{
"text": "Bairros",
"leaf": true,
"xtypeClass": "bairros"
}
]
},
{
"text": "Usuarios",
"leaf": true,
"xtypeClass": "aidfconfiguracao"
}
]
}
]
};

====================================================

================== Example my Model =================
Ext.define('terraweb.model.Menu', {
extend: 'Ext.data.Model',
fields: [
{name: 'id'},
{name: 'text'}
]
});
====================================================

================== Example my Store =================
Ext.define('terraweb.store.Menus', {
extend: 'Ext.data.Store',
requires: ['terraweb.model.Menu'],
model: 'terraweb.model.Menu',
storeId: 'Menus',
autoSync: true,
autoLoad: true,
proxy: {
type: 'rest',
noCache: false,
mode: "local",
url: 'menu2.json',
appendId: false,
reader: {
type: 'json',
root: 'menu'
},
actionMethods: {
create: 'POST',
read: 'GET',
update: 'PUT',
destroy: 'DELETE'
}
}
});
===================================================

========== Example my Panel and Combo Search ==========
Ext.define('terraweb.view.Localizador', {
extend: 'Ext.Panel',
requires: ['Ext.data.*', 'Ext.form.*'],
width: 326,
layout: 'anchor',
xtype: 'localizador',
items: [{
xtype: 'combo',
queryMode: 'local',
store: 'Menus',
displayField: 'text',
typeAhead: false,
hideLabel: true,
hideTrigger: true,
anchor: '100%',
emptyText: 'Pesquisar por Telas e Relatórios...',
valueField: 'text',
html: console.log(this.store),
listConfig: {
loadingText: 'Buscando...',
emptyText: 'Não foi localizada informações.',
border: 1,
selectOnFocus: true,
typeAhead: true,
triggerAction: 'all',
getInnerTpl: function(dados) {
return '{text}';
}
},
pageSize: 10
},
{
xtype: 'component'
}]
});
====================================================
</code>

The example above works, however, seeks only the my first dimension of array.
I need to solve this problem without changing my Store, as I use it in other parts of the system.

I get paid for a beer that can help me.

Tanks
Alberto

suzuki1100nz
4 Oct 2013, 12:51 PM
Hi
Please use code blocks in your post and where is you search code?

alberto_matos
7 Oct 2013, 3:21 AM
I'm sorry if I have not understood your question.
My code search was done in ZF2 / PHP and is returning JSON example I showed.


My quest to EXT is shown in PANEL / COMBO show that in the last block of code.


I appreciate your help.



================ Example my menu.json ===============


{
"menu": [
{
"text": "Cadastros",
"expanded": true,
"menu": [
{
"text": "Cursos",
"expanded": true,
"menu": [
{
"text": "Subcursos",
"leaf": true,
"xtypeClass": "aidfconfiguracao"
},
{
"text": "Aulas",
"leaf": true,
"xtypeClass": "aidfconfiguracao"
},
{
"text": "Bairros",
"leaf": true,
"xtypeClass": "bairros"
}
]
},
{
"text": "Usuarios",
"leaf": true,
"xtypeClass": "aidfconfiguracao"
}
]
}
]
};


====================================================


================== Example my Model =================
Ext.define('terraweb.model.Menu', {
extend: 'Ext.data.Model',
fields: [
{name: 'id'},
{name: 'text'}
]
});
====================================================

================== Example my Store =================
Ext.define('terraweb.store.Menus', {
extend: 'Ext.data.Store',
requires: ['terraweb.model.Menu'],
model: 'terraweb.model.Menu',
storeId: 'Menus',
autoSync: true,
autoLoad: true,
proxy: {
type: 'rest',
noCache: false,
mode: "local",
url: 'menu2.json',
appendId: false,
reader: {
type: 'json',
root: 'menu'
},
actionMethods: {
create: 'POST',
read: 'GET',
update: 'PUT',
destroy: 'DELETE'
}
}
});
===================================================


========== Example my Panel and Combo Search ==========
Ext.define('terraweb.view.Localizador', {
extend: 'Ext.Panel',
requires: ['Ext.data.*', 'Ext.form.*'],
width: 326,
layout: 'anchor',
xtype: 'localizador',
items: [{
xtype: 'combo',
queryMode: 'local',
store: 'Menus',
displayField: 'text',
typeAhead: false,
hideLabel: true,
hideTrigger: true,
anchor: '100%',
emptyText: 'Pesquisar por Telas e Relatórios...',
valueField: 'text',
html: console.log(this.store),
listConfig: {
loadingText: 'Buscando...',
emptyText: 'Não foi localizada informações.',
border: 1,
selectOnFocus: true,
typeAhead: true,
triggerAction: 'all',
getInnerTpl: function(dados) {
return '{text}';
}
},
pageSize: 10
},
{
xtype: 'component'
}]
});
====================================================