PDA

View Full Version : Combobox don't display displayField but valueField



lpastor
18 Aug 2009, 7:41 AM
Hello,

My combo in an EditorGrid display only the displayField but not the valueField.

If double click on my combo I can see the displayfield and after if I click on another cell I see again the valuefield.

I studied all the articles on the combobox in the FAQ and the forum and I can not find a solution.

This is the start of my code :


// Create a standard HttpProxy instance.
var proxy = new Ext.data.HttpProxy({
//url: 'app.php/users'
url: 'Mysql_Call.php?table=application&idkey=id_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_application',
root: 'data'
}, [
{name: 'id_application'},
{name: 'nom_application', mapping: 'nom_application', sortDir: 'ASC', sortType: 'asUCString', allowBlank: false},
{name: 'id_statut_application'},
{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_application',
//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) {}
}
});

// STATUT

var proxy_statut = new Ext.data.HttpProxy({
url: 'Mysql_Call.php?table=statut&idkey=id_statut',
method: 'POST'
});

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

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

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

// load the store immeditately
store_statut.load();
store.load();

// Let's pretend we rendered our grid-columns with meta-data from our ORM framework.
var userColumnsGrid = [
{header: "ID", width: 40, sortable: true, dataIndex: 'id_application'},
{header: "Libellé", width: 100, sortable: true, dataIndex: 'nom_application', editor: new Ext.form.TextField({})},
{header: "Statut", width: 100, sortable: false, dataIndex: 'id_statut_application', editor: new Ext.form.ComboBox({
typeAhead: false,
triggerAction: 'all',
lazyRender: true,//should always be true for editor
store: store_statut,
displayField: 'nom_statut',
valueField: 'id_statut',
//hiddenName:'id_statut_application',
renderer: //custom rendering specified inline
function(value) {
var r = store_statut.getById(value);
return r ? r.get('nom_statut') : '<unknown>';
}
})},
{header: "Info", width: 200, sortable: true, dataIndex: 'info_application', editor: new Ext.form.TextField({})}
];

Condor
18 Aug 2009, 7:47 AM
You're almost there, but 'renderer' is a config option of the grid column and not of the ComboBox editor.

lpastor
18 Aug 2009, 9:05 AM
Wonderful, Extraordinary, Gigantic !!!

a big thank you, Condor,

Laurent