PDA

View Full Version : problem with Combo box



ivan.rico
23 Jul 2010, 2:45 PM
hello friends,

first of all, I want to say that my english is not good, I hope to be clear in order to get some help.

I am new on ExtJs, I think it is a powerfull framework therefore I am doing some tests in order to learn how to use it.

I want to do a form with 2 combo box and a button with POST method
My progress is too slow :( I just have created 2 combos with the submit button, but I can't send de right post values to my PHP page, when I click the button the post method sends the description of the combos instead of the values (the Ids).

What is wrong here?

this is my file.js


Ext.ns("sistema");

sistema.LinkedComboBoxTutorial = {
init: function(){


var empresasStore = this.getStore();

var municipiosStore = new Ext.data.JsonStore({
autoLoad: true,
url: 'datosEmpresas.php',
baseParams:{ accion: 2 },
root: 'datos',
totalProperty: 'total',
fields: [
{name:'value', type: 'string'},
{name:'label', type: 'string'},
]
});

var comboMunicipio =new Ext.form.ComboBox({
fieldLabel: 'Municipio',
name: 'comboMunicipio',
forceSelection: true,
store: municipiosStore,
emptyText: 'Selecciona un Municipio...',
triggerAction: 'all',
displayField: 'label',
valueField: 'value',
mode: 'local',
//hideTrigger:true,
editable: false
//minChars:3
});

var comboEmpresas = new Ext.form.ComboBox({
fieldLabel: 'Empresas',
name: 'comboEmpresas',
forceSelection: true,
store : empresasStore,
emptyText: 'Seleccionar una empresa',
triggerAction: 'all',
editable: false,
displayField: 'EMPRESA',
valueField: 'CVE_EMPRESA',
width: 500,
disabled: true,
mode: 'local'

});

comboMunicipio.on('select',function(cmb,record,index){
comboEmpresas.clearValue();
comboEmpresas.enable();
empresasStore.load({
params:{
accion: 1,
municipio:record.get('value')
}
});
},this);

var panel1 = new Ext.FormPanel({
url: 'datosEmpresas.php',
title: 'Seleccione Filtros',
items: [comboMunicipio, comboEmpresas],
region: 'south',
//layout: 'form',
height: 150,
buttons: [ {text: 'Buscar',
handler: function(){

panel1.getForm().submit();
}
} ]

//iconCls: 'users'
});

var panel2 = new Ext.Panel({
region: 'center'
});

/**
* PANEL PRINCIPAL
*/
var main = new Ext.Panel({

title: 'Banco de Datos',
height:600,
layout: 'border',
defaults: {
//collapsible:true,
border: true,
bodyStyle: 'padding:10px;',
//titleCollapse: true,

},
items: [panel1,panel2]//,panel3]

});
main.render('panel');

},

getStore: function(){
var store = new Ext.data.JsonStore({
url:'datosEmpresas.php',
root:'datos',
fields: ['CVE_EMPRESA','EMPRESA']
});
return store;
}



}

Ext.onReady(sistema.LinkedComboBoxTutorial.init,
sistema.LinkedComboBoxTutorial);



thanks

ma_nepali_keta
23 Jul 2010, 11:46 PM
By Default Ext Js comboBox submit its displayfield value as a form data. To enable submit the valuefield as form data you should add hiddenName config property to your combo box setting



var comboMunicipio =new Ext.form.ComboBox({
hiddenName:'myHiddenId',
fieldLabel: 'Municipio',
name: 'comboMunicipio',
forceSelection: true,
store: municipiosStore,
emptyText: 'Selecciona un Municipio...',
triggerAction: 'all',
displayField: 'label',
valueField: 'value',
mode: 'local',
//hideTrigger:true,
editable: false
//minChars:3
});


Hope this helps.

[/HTML]

ivan.rico
24 Jul 2010, 5:29 AM
your advice is great, It works pretty fine

thank you

Thandayuthapani
15 Aug 2010, 11:30 PM
Hi i created two combo boxes for my application

One combo box mode is local and the other combo box mode is remote

In the application if i enter a word in the combo with local mode it lists all the datas in that word, but if i enter a word in the combo with remote mode it does not lists all the datas in that word after giving 4 letters only it lists..

How to resolve this problem?

The following is my code..

CQ.Ext.onReady(function(){

var language = [['en'],
['fr'],
['de'],
['it']
];

var language_store = new CQ.Ext.data.SimpleStore({
fields: ['id'],
data : language
});

var language_combo = new CQ.Ext.form.ComboBox({
store: language_store,
fieldLabel: 'Language',
displayField:'id',
id : 'language',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a Language...',
editable: true,
allowBlank: false
});

var lang = "de";
var store = new CQ.Ext.data.JsonStore({
url: '/bin/logica/autocomplete?lang='+lang ,
idProperty: 'id',
fields: ['id']
});

var search_combo = new CQ.Ext.form.ComboBox({
store:store,
fieldLabel: 'Search',
displayField:'id',
typeAhead: true,
mode: 'remote',
queryParam: 'term',
editable: true,
hideTrigger: true,
selectOnFocus:true,
allowBlank: false
});

var fp = new CQ.Ext.FormPanel({
frame: true,
title:'Auto Search',
labelWidth: 110,
width: 600,
renderTo:'autosearch',
bodyStyle: 'padding:0 10px 0;',
items: [language_combo,search_combo]
});
});


Regards

Thandayuthapani

Animal
15 Aug 2010, 11:46 PM
You are checking to see if it's querying the server, and finding that it is not?

http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.ComboBox&member=minChars

Thandayuthapani
16 Aug 2010, 12:52 AM
Thanks animal i got it