PDA

View Full Version : How to put a dynamic form on a layout Dialog?



daihuarong
14 Oct 2007, 7:38 PM
Hello,everyboy, I want to put a dynamic form on a Layout Dialog without Tab,How can I do?
I hope someone can help me,my code like this:

var operationForm = new Ext.form.Form({
method:'post',
url:'save.action',
labelAlign:'right'
});
operationForm.fieldset({},id_text,dict_text,name_text,desc_text,
shortcode_text,default_text);
operationForm.column({width:600, labelWidth:100});
operationForm.render('a-addInstance-form');
operationForm.applyIfToFields({width:255});
operationForm.end();
function showDialog(){
aAddInstanceDlg=createDialog("showDialog","Add");
var layout = aAddInstanceDlg.getLayout();
layout.beginUpdate();
layout.add('center',new Ext.ContentPanel('a-addInstance-form',{}));
layout.endUpdate();
aAddInstanceDlg.show();
}
function createDialog(dialogName,title){
if(!dialog){
dialog = new Ext.LayoutDialog(dialogName, {
width: 400,
height: 250,
modal: true,
shadow: "drop",
resizable: true,
collapsible: false,
proxyDrag: true,
center: {
autoScroll: true,
tabPosition: "top",
alwaysShowTabs: true
}
});
dialog.addKeyListener(27, dialog.hide, dialog);
dialog.addButton('ok',handlerAdd,operationForm);
dialog.addButton('cancel', dialog.hide, dialog);
}
dialog.setTitle(title);
return dialog;
}



but it show me like this
C:\Documents and Settings\wuxuea\My Documents\My Pictures\1.gif
,this is not what I want

michaelmoreno
17 Oct 2007, 11:12 PM
I think that if you move "operationForm.render('a-addInstance-form'); " to after you've added the center ContentPanel it should work.

amichelin
22 Oct 2007, 5:02 AM
Yes this run ok.

I try in my dialog.

if(!dialog){ // lazy initialize the dialog and only create it once
dialog = new Ext.LayoutDialog("hello-dlg", {
modal:true,
width:400,
height:400,
shadow:true,
minWidth:400,
minHeight:400,
proxyDrag: true,
center: {
autoScroll:true,
tabPosition: 'top',
closeOnTab: false,
alwaysShowTabs: false
}
});
dialog.addKeyListener(27, dialog.hide, dialog);
dialog.addButton('Close', dialog.hide, dialog);
var layout = dialog.getLayout();
layout.beginUpdate();
var dialogPanel = new Ext.ContentPanel('center', {title: 'The First Tab'});

var top = Edit(); --> here is created the form element and return.

top.render('center'); ==> here i render the form into the center panel

layout.add('center', dialogPanel);

layout.endUpdate();

This happens inside the grid.