PDA

View Full Version : menus.js



captainm1uk
5 Nov 2007, 6:18 AM
Hi

I am using the menus.js file to create a toolbar menu. I am using this as I want to enable/ disable the buttons through ext rather than extnd.

I want to have a save button - what is the syntax for firing a submit to the server ?

Thanks

RWaters
5 Nov 2007, 7:53 AM
in general you just need to find the form element and call submit on it. Domino doesn't really make this easy on us as it doesn't put an id attribute on the form. In most cases unless you're adding additional form tags onto the page you can use document.forms[0]

FYI: If you used Ext to create an Ext.form then it will generate another form tag and the above wont work.

captainm1uk
5 Nov 2007, 10:26 AM
Hi

This is the code in the js header so there is no ext frm - fro what you are saying then I can just use document.forms[0].submit ?




/*
* Ext JS Library 1.1.1
* Copyright(c) 2006-2007, Ext JS, LLC.
* licensing@extjs.com
*
* http://www.extjs.com/license
*/
Ext.onReady(function(){
Ext.get('mb1').on('click', function(e){
Ext.MessageBox.show({
title: 'Feedback',
msg: 'Please enter any relevant feedback:',
width:400,
buttons: Ext.MessageBox.OKCANCEL,
multiline: true,
fn: showResultText,
animEl: 'mb1'
});
});

var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var myDate = day + "/" + month + "/" + year
//var myName = document.forms.Name.value

function showResultText(btn, text){
if(btn=='ok'){
document.forms[0].DeptFeedback.value=document.forms[0].DeptFeedback.value+"Comments added by "+ " on "+ myDate +"\r"+text+"\r"+"\r"
}
};
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'qtip';

var department = new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform:'Department',
width:120,
forceSelection:true
});
department.applyTo('Department')

var depteffected = new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform:'DeptEffected',
forceSelection:true
});
depteffected.applyTo('DeptEffected')

var myName = new Ext.form.TextField({
vtype:'alpha',
allowBlank:false,
disableKeyFilter:true
});

myName.applyTo('fName');
var myPhone = new Ext.form.TextField({
allowBlank:false,
vtype:'alphanum'
});

myPhone.applyTo('phoneno');
var email = new Ext.form.TextField({
allowBlank:false,
vtype:'email'
});

email.applyTo('email');

var grow = new Ext.form.TextArea({
allowBlank:false,
width:600, grow:true
});
grow.applyTo('Comments');

var grow = new Ext.form.TextArea({
disabled: true,
//rendered: true,
width:600, grow:true
});
grow.applyTo('DeptFeedback');
});

captainm1uk
6 Nov 2007, 7:17 AM
I am trying to add a toolbar menu using the js files from the ext1.1 examples and I am reading through the tutorial. So far I get an error in IE and FF is ok.

The error in ie is render is null or not an object

Here is the code from the tutorial


Ext.onReady(function() {
//Start menu here
var menu = new Ext.menu.Menu({
id: 'mainMenu',
items: [{
text: 'Edit',
handler: clickHandler
},
new Ext.menu.Item({
text: 'Close',
handler: clickHandler
}),
]
});

var tb = new Ext.Toolbar('toolbar', [{
cls: 'x-btn-text-icon bmenu', // icon and text class
text:'Document Options',
// icon: 'check.gif',
menu: menu // assign our menu to this button
}
]);

function clickHandler() {
document.forms[0].submit;
}

function checkHandler() {
alert('Checked a menu item');
}
//Finish menu here
});


I am trying to create a button with a drop down list of Edit and Close.

If I view this through firefox - the url that shows in the status bar at the bottom of the screen says \\server\db\form?openform (file://\\server\db\form?openform) yet the code above states a submit

Can anyone help

Thanks

jratcliff
6 Nov 2007, 9:02 AM
In your "items" array, you have a comma after the last item. IE doesn't like that. Remove the comma and all should be good.

captainm1uk
6 Nov 2007, 10:28 AM
Hi
I have been pulling my hair out all day with this and it is something you just would not see (unless you know what you are doing :) ). All my aim is for this project (when I eventually get it finished) is to have a form with a drop down list on it - in the drop down list I have save doc and close doc. I have tried document.forms[0].submit under the clickHandler - but nothing happens - it just puts a # at the end of the url.

The form itself is a notes doc and the fields are "ext i sized" using the form example. The bit which does the rendering is in the js header - there is no var frm etc so it is just using the domino form - is it still possible to do this with document.forms[0].submit ?

mth96a
8 Nov 2007, 6:27 AM
will give you allot more information to what is happening and errors that are generated. And yes that code should work just fine.

here is an example button i use with validation


ws = new Ext.nd.UIWorkspace();
if(document.forms[0].job.value ==''){
ws.Prompt('OK', '', 'You must put in an account or job number');

}
else{
if(document.forms[0].projectmgr.value ==''){
ws.Prompt('OK', '', 'You must have an approver, contact ' + (if(document.forms[0].projectmgr_1 == ''{'the Project Manager'} else {document.forms[0].projectmgr_1.value}) );
}
else{
parent.document.forms[0].st1.value = parseFloat(parent.document.forms[0].st1.value) + parseFloat(document.forms[0].sttotal.value);
parent.document.forms[0].st2.value = parseFloat(parent.document.forms[0].st2.value) + parseFloat(document.forms[0].ottotal.value);
parent.document.forms[0].st2_2.value = parseFloat(parent.document.forms[0].st2_2.value) + parseFloat(document.forms[0].vactotal.value);
parent.document.forms[0].st2_1.value = parseFloat(parent.document.forms[0].st2_1.value) + parseFloat(document.forms[0].rig.value);
parent.document.forms[0].st2_3.value = parseFloat(parent.document.forms[0].st2_3.value) + parseFloat(document.forms[0].vactotal_1.value);
parent.document.forms[0].approvers1.value = parent.document.forms[0].approvers1.value + ", " + document.forms[0].projectmgr.value + "/rcc";
document.forms[0].submit();}}