PDA

View Full Version : dialog box



anusha
6 Aug 2007, 11:06 PM
Hi All ,

I am a newbie ,i have created a dialog box which has edit and cancel buttons.

here is my code,




var EditLayout = function(){
var dialog, showBtn;

var toggleTheme = function(){
Ext.get(document.body, true).toggleClass('ytheme-gray');
};

return {
init : function(){
showBtn = Ext.get('show-dialog-btn');
// attach to click event
showBtn.on('click', this.showDialog, this);

},


showDialog : function(){
if(!dialog){
dialog = new Ext.LayoutDialog("hello-dlg", {
modal:true,
width:600,
height:400,
shadow:true,
minWidth:300,
minHeight:300,
proxyDrag: true,

center: {
autoScroll:true,
tabPosition: 'top',
closeOnTab: true,
alwaysShowTabs: false
}
});
dialog.addKeyListener(27, dialog.hide, dialog);
dialog.addButton('Edit', dialog.hide, dialog);
dialog.addButton('Cancel', dialog.hide, dialog);

var layout = dialog.getLayout();
layout.beginUpdate();

layout.add('center', new Ext.ContentPanel('center', {title: 'Edit'}));

layout.endUpdate();
}
dialog.show(showBtn.dom);
}


};
}();

Ext.EventManager.onDocumentReady(EditLayout.init, EditLayout, true);

});



within the dialog box i am displaying textboxes ,on click of edit button i need to validate these textboxes, how can i call a function from within this code to validate my textboxes on click of edit button?


Thanks
Anusha

anusha
7 Aug 2007, 9:13 PM
Hi All,

just in case if anyone is facing the same issue,
we can add a handler tag and write the code required on click of edit button as shown below




dialog.addButton({text: 'Edit',handler: editFunction},dialog);
dialog.addButton({text: 'Cancel'},dialog.hide,dialog);



Thanks & Regards
Anusha

ashishgandhi
8 Aug 2007, 3:37 AM
hey ,
you can use "allowBlank:false" for not to allow blank textbox
nand for validation you can use "vtype:alpha"

e.g,

new Ext.form.TextField({
fieldLabel: 'Name',
name: 'department_name',
allowBlank: false,
width:190,
align:'right',
vtype:'alpha'
}),