1. use an iFrame and an external page
Drawback: no offline availability
2.do some DOM-injection and create the buttons at runtime
Drawback: a bit tricky with placement and so on
And then there is:
3. Adis idea to transform a textattribute into a button.
The nice thing is, that you can use the normal formeditor to place it.
So I took the idea further and applied the CRM 4.0 styles to make it look 100% native and more generic to use. (it even reacts to mousedown as expected - hehe ;-)
What to do:
- create a textattribute (you can set searchable to "no" so the attribute doesn't show up in advanced search
- put it on the form
- make it "readonly" (Thanks Marcel!)
- copy the sourcecode into the onLoad event.
- replace the fieldname "bwt_button1" in the last line with your attributename.
- create your functions to tell the button what to do when clicked.
- have fun
source:
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//CRM 4.0-Style button creator
//Creates a Button from a Textattribute.
//For every Button you need, create a nText Attribute and place it on the Form
//mario raunig, world-direct 04/2008
function create_button_from_textattribute(fieldname, buttontext, buttonwidth,clickevent)
{
functiontocall=clickevent;
crmForm.all[fieldname].DataValue = buttontext;
crmForm.all[fieldname].style.borderRight="#3366cc 1px solid";
crmForm.all[fieldname].style.paddingRight="5px";
crmForm.all[fieldname].style.borderTop="#3366cc 1px solid";
crmForm.all[fieldname].style.paddingLeft="5px";
crmForm.all[fieldname].style.fontSize="11px";
crmForm.all[fieldname].style.backgroundImage="url(/_imgs/btn_rest.gif)";
crmForm.all[fieldname].style.borderLeft="#3366cc 1px solid";
crmForm.all[fieldname].style.width=buttonwidth;
crmForm.all[fieldname].style.cursor="pointer";
crmForm.all[fieldname].style.lineHeight="18px";
crmForm.all[fieldname].style.borderBottom="#3366cc 1px solid";
crmForm.all[fieldname].style.backgroundRepeat="repeat-x";
crmForm.all[fieldname].style.fontFamily="Tahoma";
crmForm.all[fieldname].style.height="20px";
crmForm.all[fieldname].style.backgroundColor="#cee7ff";
crmForm.all[fieldname].style.textAlign="center";
crmForm.all[fieldname].style.overflow="hidden";
crmForm.all[fieldname].attachEvent("onmousedown",push_button);
crmForm.all[fieldname].attachEvent("onmouseup",release_button);
crmForm.all[fieldname].attachEvent("onclick",functiontocall);
}
function push_button(){
window.event.srcElement.style.marginLeft="1px";
window.event.srcElement.style.marginTop="1px";
}
function release_button(){
window.event.srcElement.style.marginLeft="0px";
window.event.srcElement.style.marginTop="0px";
}
// tell the button what to do
function testfunction()
{
alert('Ta-da!');
}
// create the button
create_button_from_textattribute('bwt_button1', 'What a nice CRM 4.0 Button','184px',testfunction);
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
0 komentar:
Posting Komentar