PDA

View Full Version : Combo Serach in All Nodes of Array



alberto_matos
10 Oct 2013, 6:31 AM
Combo Serach in All Nodes of Array


I am sending the question again.
Is my first time here and nobody answer my queston, i'm sad.


My code search was done in ZF2 / PHP and is returning JSON example I showed.


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'
}]
});
====================================================

Gary Schlosberg
12 Oct 2013, 5:48 AM
Thanks for adding the CODE tags.
http://www.sencha.com/forum/showthread.php?273155

You data looks like it might be for a tree or menu. It seems you're asking for a combo to display and search over that data. You'll probably need to modify it to work with the combobox.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.ComboBox
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.ComboBox-cfg-store