PDA

View Full Version : retrieve value of rowselected after a dbclick and use it as value of a textfield



baoumar
19 Jul 2010, 1:32 AM
hi,
excuse me i don't speak english well,i'm a french
I have a gridpanel in a window, I want when I just double click on a line of gridpanel retrieve the values of the line and use them as values textfield that I created in another frompanel,
I hope you understand me and I'm really blocked for a week for it,
I am a student that's my end of the year.

it is my code:


simpleForm = new Ext.FormPanel({

frame: true,
title: '',
bodyStyle: 'padding:5px 5px 0',
width: 500,
items: [diplomeField,hobbieField,refField,carriereField,groupField,seopointsField,expField],
buttons: [{
text: 'Chercher',
handler: function () {
if (!sentGrid) {
var sentDS = new Ext.data.JsonStore({
url: 'database.php',
idProperty: 'user_id',
root: 'data',
fields: ['user_id', 'user_photo','user_lname','user_fname','profilevalue_14','user_email','userpoints_count','group_title','education_degree','profilevalue_11','employment_employer'],
listeners: {
loadexception: function () {
Ext.MessageBox.alert('Message', 'Chemin introuvable');
}
}
});

function displayFormWindow(){
if(!contactWindow.isVisible()){
// resetContactForm();
contactWindow.show();
} else {
contactWindow.toFront();
}
}
var sentGrid = new Ext.grid.EditorGridPanel({
store: sentDS,
id:'sentGrid',
enableColLock:false,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
bbar: new Ext.PagingToolbar({
pageSize: 20,
store: sentDS,
displayInfo: true
}),
tbar: [
{
text: 'Contacter',
tooltip: 'contacter...',
//iconCls:'add',
handler: displayFormWindow
}],
columns: [{
header: 'ID',
width: 20,
sortable: true,
dataIndex: 'user_id'
},
{
header: '',
width: 50,
sortable: true,
renderer:renderIcon,
dataIndex: 'user_photo'
},
{
header: 'Prenom',
width: 50,
sortable: true,
dataIndex: 'user_fname'
}, {
header: 'Nom',
width: 70,
sortable: true,
dataIndex: 'user_lname'
},
{
header: 'Email',
width: 100,
sortable: true,
dataIndex: 'user_email'
},
{
header: 'Seopoints',
width: 30,
sortable: true,
dataIndex: 'userpoints_count'
},
{
header: 'Groupes',
width: 70,
sortable: true,
dataIndex: 'group_title'
},
{
header: 'Diplomes',
width: 100,
sortable: true,
dataIndex: 'education_degree'
},
{
header: 'Hobbies',
width: 150,
sortable: true,
dataIndex: 'profilevalue_14'
}
,
{
header: 'References',
width: 150,
sortable: true,
dataIndex: 'profilevalue_11'
},
{
header: 'Carrieres',
width: 100,
sortable: true,
dataIndex: 'employment_employer'
}
],
title: '',
stripeRows: true,
border: true,
height: 300,
width: 700,
align:'center',
autoScroll: true,
});

function onSentGridContextMenu(grid, rowIndex, e) {
e.stopEvent();
var coords = e.getXY();
SentGridContextMenu.rowRecord = grid.store.getAt(rowIndex);
grid.selModel.selectRow(rowIndex);
sentGridSelectedRow=rowIndex;
SentGridContextMenu.showAt([coords[0], coords[1]]);
}

function contactMembreContextMenu(){

displayFormWindow();
}

function afficheMembreContextMenu(){

}

sentGrid.addListener('rowcontextmenu', onSentGridContextMenu);
SentGridContextMenu = new Ext.menu.Menu({
id: 'sentGridEditorGridContextMenu',
items: [
{ text: 'Contacter', handler: contactMembreContextMenu },
{ text: 'afficher details', handler: afficheMembreContextMenu }
]
});






var w1 = new Ext.Window({
title: 'Resultat de la recherche',
region:'west',
collapsible: true,
maximizable: true,
closible:false,
width: 800,
height: 500,
layout: 'fit',
plain: true,
bodyStyle: 'padding:5px;',
contentEl: 'mygrid',
items:sentGrid
});
w1.show();
}
sentGrid.getStore().load({
params: simpleForm.getForm().getValues()
});
}
},
{
text: 'Annuler',
handler: function () {
simpleForm.getForm().reset();
if (sentGrid) {
sentGrid.getStore().removeAll();
w1.hide();
}
}
}]
});

var w = new Ext.Window({
title: 'Recherche de Membre',
region:'east',
collapsible: true,
maximizable: true,
closible:true,
width: 500,
height: 300,
layout: 'fit',
plain: true,
bodyStyle: 'padding:5px;',
contentEl: 'myform',
items:simpleForm
});
w.show();

Condor
19 Jul 2010, 1:45 AM
Use:

var record = grid.getStore().getAt(rowIndex);
formPanel.getForm().loadRecord(record);