PDA

View Full Version : Combobox problem to save



lpastor
17 Aug 2009, 1:51 PM
Hello,

I use a combo in a form, the combo display well data from the second store, but when I save, the combo don't save anything.

When I select a row in my grid, the combo display juste Empty...

In my database, I put a correct number for id_statut_application that link with id from status.

Here is my data :


APPLICATION
-------------
id
name_application
id_statut_application
info_application


STATUS
--------
id
name_status



Application data is loaded in a store named store and status in a store named store_status.

My combo display status

Here is the code to build my form :



buildForm : function() {
return [
{fieldLabel: 'name', name: 'name_application', allowBlank: false},
new Ext.form.ComboBox({
fieldLabel: 'Status',
hiddenName:'id_status_application',
store: store_status,
valueField:'id',
displayField:'nom_status',
typeAhead: true,
//mode: 'local',
triggerAction: 'all',
emptyText:'Empty...',
selectOnFocus:true,
width:190
}),
{fieldLabel: 'info', name: 'info_application', allowBlank: true}
];
},The rest of my form is well saved when I click on update or create.

What's wrong ?

lpastor
18 Aug 2009, 4:03 AM
Perhaps my problem is because I have the same name id between both table ?

This is my both storages (store and store_status) :


// Create a standard HttpProxy instance.
var proxy = new Ext.data.HttpProxy({
//url: 'app.php/users'
url: 'Mysql_Call.php?table=application',
method: 'POST'
});

//Typical JsonReader. Notice additional meta-data params for defining the core attributes of your json-response
var reader = new Ext.data.JsonReader({
totalProperty: 'total',
successProperty: 'success',
idProperty: 'id',
root: 'data'
}, [
{name: 'id'},
{name: 'nom_application', mapping: 'nom_application', sortDir: 'ASC', sortType: 'asUCString', allowBlank: false},
{name: 'info_application'} //again, the order shown here does NOT matter
]);

// The new DataWriter component.
var writer = new Ext.data.JsonWriter();

// Typical Store collecting the Proxy, Reader and Writer together.
var store = new Ext.data.Store({
id: 'id',
//restful: true, // <-- This Store is RESTful
//baseParams:{task: "readData"}, // Commande de lecture des data
proxy: proxy,
reader: reader,
writer: writer, // <-- plug a DataWriter into the store just as you would a Reader
listeners: {
write : function(store, action, result, response, rs) {
//App.setAlert(response.success, response.message);
//Ext.example.msg(response.success, response.message);
//store.load(); // Ajouté pour forcer le rafraichissement - Add to force the refresh of the data - LP
//Ext.Msg.alert('Link', 'Ca gaz');

}
}
});

// STATUS

var proxy_status = new Ext.data.HttpProxy({
url: 'Mysql_Call.php?table=status',
method: 'POST'
});

var reader_status = new Ext.data.JsonReader({
totalProperty: 'total',
successProperty: 'success',
idProperty: 'id',
root: 'data'
}, [
{name: 'id'},
{name: 'nom_status', mapping: 'nom_status', sortDir: 'ASC', sortType: 'asUCString', allowBlank: false},
{name: 'info_status'} //again, the order shown here does NOT matter
]);

var writer_status = new Ext.data.JsonWriter();

var store_status = new Ext.data.Store({
id: 'id',
//restful: true, // <-- This Store is RESTful
//baseParams:{task: "readData"}, // Commande de lecture des data
proxy: proxy_status,
reader: reader_status,
writer: writer_status, // <-- plug a DataWriter into the store just as you would a Reader
listeners: {
write : function(store_status, action, result, response, rs) {}
}
});