PDA

View Full Version : Problems with editgrid



pierre26
11 Dec 2012, 6:59 AM
Hello everybody,

I would say if you know some editgrid tutorials.
I have problems : i must do editgrid manipulations and it doesn't work.

- i have try to integrate a default value in a combobox inside the grid (it doesn't work) but the others outside the grid i can do insert default value in the combobox with a setValue
- i have try to disable a row if i have activate a checkbox or i have select a value in the combobox
And finally, i would change the row color when i have always treated the row.




fm = Ext.form;

//Décalaration de la case à cocher de l'action de relevé


var checkColumn = new Ext.grid.CheckColumn({
header: 'Non relevé',
dataIndex: 'releve',
width: 55,
checked: true,
allowBlank: true
});


combo = new fm.ComboBox({
id : 'combo',
triggerAction: 'all',
displayField: 'name',
valueField: 'name',
allowBlank: true,
store: new Ext.data.JsonStore({
autoload: true,
url: './capture/saisie/serveur_etat.php',
root: 'lesetat',
fields:['id', 'name']
})

});








cm = new Ext.grid.ColumnModel({


defaults: {
sortable: true
},
columns: [
checkColumn,
{
id: 'nom_piege',
header: 'Code',
dataIndex: 'nom_piege',
width: 75,
allowBlank: true

},{
id: 'commune',
header: 'commune',
dataIndex: 'nom',
width: 75,
allowBlank: true
},{
id: 'etat_piege',
header: 'Etat_piege',
dataIndex: 'EtatPiege',
width: 250,
allowBlank: true,
editor: combo,
renderer: Ext.util.Format.comboRenderer(combo)
},{
id: 'effectif',
header: 'Effectifs',
align: 'center',
renderer: function(value, metadata, record) {

tp = '<?php echo $_SESSION['type_piege'];?>';
if (( typ_piege == 1) || (tp == 1))
{
return '<a onclick="frm_effectif_pondoir.show();" target="_blank" ><img src="./logo/AddFileButton.png" width="20" align="center"></a>';
}
else
{

return '<a onclick="frm_effectif.show();" target="_blank" ><img src="./logo/AddFileButton.png" width="20" align="center"></a>';
}

}
}
]
});




store = new Ext.data.JsonStore({
root:'rows',
IdProperty: 'code_piege',
autoSave: true,
fields : [
{
name: 'releve'
},
{
name : 'nom_piege'
},
{
name : 'nom'
},
{
name : 'EtatPiege'
},
{

name : 'Effectifs'
}


],
url : './capture/saisie/serveur_tableau.php',
//permet d'effectuer des enregistrements dans la base de données
writer : new Ext.data.JsonWriter({
writeAllFields: false,
encode:true,
listful : true

}),


});

//déclaration du tableau
grid = new Ext.grid.EditorGridPanel({
id : 'tableau',
cls : 'custom-first-last',
sm: new Ext.grid.RowSelectionModel(
{
singleSelect: true,
listeners: {
rowselect: function(sm, row, rec) {
//alert(rec.get('nom_piege'));
le_piege = rec.get('nom_piege');
Ext.getCmp('code_piege').setValue(le_piege);
}
}
}),
hidden: true,
store: store,
cm: cm,
writer: writer,
width: 2000,
height: 500,
plugins : checkColumn,
listeners: {
afteredit: function(e){
Ext.Ajax.request({
url: './capture/saisie/serveur_captureC.php',
params: {
field: e.field,
value: e.value,
piege: le_piege,
date_ident: Ext.getCmp('dateIdent').getValue()
},
success: function(resp,opt) {
rep = resp.responseText;

},
failure: function(resp,opt) {
//e.record.reject();
}

})
}
},

tbar: [{

text : 'Enregistrer',
handler : function(){
store.save();
}

}]
});


thank you for your response

Pierre

mitchellsimoens
13 Dec 2012, 7:21 AM
First issue is the combobox's default value correct? I have usually extended the EditorGridPanel and overrode the preEditValue method.

pierre26
13 Dec 2012, 8:13 AM
Hello !!
Thank you for your response !!

Where i find this method ?

pierre26
19 Dec 2012, 1:34 AM
Yes my value is not correct.
I have found the problem
My SQL query is not correct and now i can show in the grid default value
But, i have always same others problems