PDA

View Full Version : passing data from grid to form in window



vironitronox
22 Nov 2007, 1:28 AM
Hey all,

I hope somebody can help me with this problem, because it's giving me a headache...

I've got a gridPanel with a number of rows filled from a dataStore. Above this grid is an 'edit' button. When clicked, a window opens with a form. I need the project_id form the selected row to be passed to the form, so that I can get the data I need to fill the form.

part of my grid:


var grid = new Ext.grid.GridPanel({
title: 'Overzicht bestaande projecten',
el:'prj-view',
ds: ds,
sm:sm,
cm: colModel,
height: 768,
width: 1024,
frame: true,
iconCls:'dpdk',
tbar:[{
text: 'Nieuw project',
id: 'add-btn',
tooltip: 'Voeg een nieuw project toe',
iconCls:'add'
},'-',{
text: 'Wijzig project',
id: 'edit-btn',
tooltip: 'Wijzig het geselecteerde project',
iconCls:'edit'
},'-',{
text:'Verwijder project',
tooltip:'Verwijder het geselecteerde project',
iconCls:'delete',
handler: delMessageBox
}]
});

Any help will be greatly appreciated.

Thanks in advance

santosh.rajan
22 Nov 2007, 1:53 AM
get the grids rowselection model. which will you the row clicked.

santosh.rajan
22 Nov 2007, 1:57 AM
var rec = grid.getSelectionModel().getSelected();

vironitronox
22 Nov 2007, 2:05 AM
I allready use a selectionModel within the grid (when I dblClick a row, a link gets opened), but I'm not able to send the data from the selected row to my form within a window.

I open the window from the form with the

var button = Ext.get('edit-btn');

button.on('click', function(){

method.

santosh.rajan
22 Nov 2007, 2:17 AM
Give yr grid and id. make sure the selection model is row selection model.
then wherever you want the data
Ext.getCmp('gridid').getSelectionModel.getSelected()

vironitronox
22 Nov 2007, 2:57 AM
I tried it, but it didn't work out. I gave my gridPanel an id (grid-view) and called it from the form via:

var prj_id = Ext.getCmp('grid-view').getSelectionModel.getSelected().data['project_id'];
but it gave me the error:

Ext.getCmp("grid-view") has no properties

hendricd
22 Nov 2007, 6:41 AM
var grid = new Ext.grid.GridPanel({
title: 'Overzicht bestaande projecten',
el:'prj-view',
id:'projects-grid',
ds: ds,
sm:sm,
cm: colModel,
height: 768,
width: 1024,
frame: true,
iconCls:'dpdk',
tbar:[{
text: 'Nieuw project',
id: 'add-btn',
tooltip: 'Voeg een nieuw project toe',
iconCls:'add'
},'-',{
text: 'Wijzig project',
id: 'edit-btn',
tooltip: 'Wijzig het geselecteerde project',
iconCls:'edit',
handler: function(){
var recordId = Ext.getCmp('projects-grid').getSelectionModel().getSelected().data.project_id;
updateYourForm(recordId);
}
},'-',{
text:'Verwijder project',
tooltip:'Verwijder het geselecteerde project',
iconCls:'delete',
handler: delMessageBox
}]
});