PDA

View Full Version : problem with combo



ren_diesel
1 Dec 2009, 10:21 AM
Hi everyone,

i hope you can help me on this, im trying to load a combo from a data store, but my filed still empty, i dont know what im doing wrong this is my code





function displayFormWindow(){
MenuCreateWindow.show();

}

var comboStore = new Ext.data.Store({
id: 'ComboStore',
proxy: new Ext.data.HttpProxy({
url: 'asisweb/menu/combo_team.php',
method: 'POST'
}),
baseParams:{ task: "COMBO"},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'team_id'
},[
{name: 'TeamID', mapping: 'team_id'},
{name: 'Name', mapping: 'name'}
])
});

comboStore.load();

var teamf = new Ext.form.ComboBox({
id:'grupo',
fieldLabel: 'Grupo',
store: comboStore,
mode: 'local',
displayField: 'NAME',
allowBlank: false,
valueField: 'TEAM_ID',
anchor:'95%',
triggerAction: 'all'
});

var MenuForm = new Ext.FormPanel({
labelAlign: 'top',
bodyStyle:'padding:5px',
width: 600,
items: [{
layout:'column',
border:false,
items:[{
columnWidth:0.5,
layout: 'form',
border:false,
items: [namef, teamf, descriptionf]
}]
}],
buttons: [{
text: 'Guardar y Cerrar',
handler: createMenu//createThePresident
},{
text: 'Cancelar',
handler: function(){
MenuCreateWindow.hide();
}
}]
});

MenuCreateWindow = new Ext.Window({
id: 'FormMenu',
title: 'Crear Nuevo Menu',
closable:true,
width: 610,
height: 250,
plain:true,
layout: 'fit',
items: MenuForm
});



thanks for the help

husniadil
1 Dec 2009, 11:56 AM
It's prefer to change mode: 'local' to mode: 'remote' in the ComboBox config options, and eliminate comboStore.load();.

Make sure the return value of : asisweb/menu/combo_team.php is valid (accepted by your fields on store definition).
example:
{"results":[{"team_id":"1","name":"team 1"},{"team_id":"2","name":"team 2"},{"team_id":"3","name":"team 3"}]}



becareful, your displayField and valueField are not same on the field definition...

var teamf = new Ext.form.ComboBox({
...
displayField: 'NAME',
valueField: 'TEAM_ID',
...
});

those config options should match with your field definition on the store..

change them to: Name, and TeamID as they are case-sensitive

ren_diesel
1 Dec 2009, 12:36 PM
Hi husniadil, Thanks a lot with the case-sensitive tip, is one of the problems in my query to.

now is fixed, did i mention thanks :D

husniadil
1 Dec 2009, 1:30 PM
nevermind :D