PDA

View Full Version : Newbie having problem loading form from js variables...Can someone please take a look



davisty
27 May 2011, 6:46 AM
Hello,

Im a newbie trying to load a form with js variable data. The data is not being loaded on the screen. What am I doing wrong? The data is being pulled in to the function. I can display it with alert boxes. It is setup as follow:

function doWindow(gridThis) {
var record = gridThis.selModel.getSelected();
var shipper = record.get('MHSCOD');
var consign = record.get('MHCCOD');
var notify = record.get('MHNCOD');
var forward = record.get('MHFCOD');
var hdrwin = new Ext.Window({
height : 240,
width: 350,
bodyStyle:'padding:5px 5px 0',
layout: 'form',
items :[{
fieldLabel: 'Shipper',
name: 'shipper'
},{
fieldLabel: 'Consignee',
name: 'consign'
},{
fieldLabel: 'Notify',
name: 'notify'
}, {
fieldLabel: 'Forwarder',
name: 'forward'
}],
buttons: [{
text : 'Close',
handler: function(){
hdrwin.close();
}
}]
});
hdrwin.show();
}

davisty
27 May 2011, 1:28 PM
Can someone please help. I want to convince my company to go to this framework.

Ive tried everything. It seems that it shouldnt be so hard to update a textfield

Tim Toady
27 May 2011, 8:04 PM
You're not telling it to load anything. You just have a bunch of variables and a window with a form in it. If you wanted to load it from a record and your form fields had the same names as the fieldnames for your record you could simply use yourform.getForm().loadRecord(record);

davisty
28 May 2011, 9:52 AM
Ive tried that. Because its defined as a window, Im getting getForm is not a function ...

Tim Toady
28 May 2011, 11:18 AM
Sorry, I should have looked more closely. You need a form as the child of the window and the windows layout as 'fit'.

skirtle
28 May 2011, 4:55 PM
What you've created is a window with a form layout. To use loadRecord() you'll need an Ext.form.BasicForm. As Tim suggests, the easiest way to create one of those is to put an Ext.form.FormPanel in your window and then call getForm() on the FormPanel.

If you don't want to use loadRecord() you could instead just set the values directly on each field:


function doWindow(gridThis) {
var record = gridThis.selModel.getSelected();
var shipper = record.get('MHSCOD');
...

var hdrwin = new Ext.Window({
...
items :[{
fieldLabel: 'Shipper',
name: 'shipper',
value: shipper
}, ...],
...
});

hdrwin.show();
}

davisty
29 May 2011, 5:43 AM
Thank Yall VERY MUCH. Your suggestions worked...

I LOVE this stuff. When I get pass this little learning curve, look out :))

We can close this now. How do I do that ?

fay
29 May 2011, 6:00 AM
We can close this now. How do I do that ?

Edit your post's title.

davisty
29 May 2011, 12:52 PM
Will do, thank you RollTide ...

davisty
29 May 2011, 12:58 PM
Tried ... Still not sure ...the edit edit post part

I feel so stupid asking these questions