Difference between revisions of "HowTo:Add a Custom Print Button to a Form"

From AgileApps Support Wiki
imported>Aeric
(Created page with "This code adds a '''[Custom Print]''' button to a Form, when placed in an On Load Form Script. In this case, the goal is to restrict a user who has access to that form to…")
 
imported>Aeric
Line 1: Line 1:
<noinclude>
{{Orientation | audience | level | N}}
</noinclude>...First line here...
:* Activate the noinclude block so it doesn't appear when Guides are aggregated.
:* audience = Users, Designers, Developers
:* level = Beginner, Intermediate, Advanced
:* N = 1, 2, 5, 10, 15, 20, 30 (minutes)
===Heading===
Top level heads in HowTo Guides are H3's, so they can be combined into a big PDF, one day.
<!--
  No category for a HowTo Guide.
  They're reached from the index page in the Nav Bar.
  No point having an entry in the categories list, as well.
-->
This code adds a '''[Custom Print]''' button to a [[Form]], when placed in an On Load [[Form Script]]. In this case, the goal is to restrict a user who has access to that form to a specific template. (The standard Print operation makes all templates available. A standard [[Action]] button, meanwhile, is present in every form. This code puts the button in a specific form, to restrict template access for users whose role causes it to be displayed.)
This code adds a '''[Custom Print]''' button to a [[Form]], when placed in an On Load [[Form Script]]. In this case, the goal is to restrict a user who has access to that form to a specific template. (The standard Print operation makes all templates available. A standard [[Action]] button, meanwhile, is present in every form. This code puts the button in a specific form, to restrict template access for users whose role causes it to be displayed.)
:<syntaxhighlight lang="javascript" enclose="div">
:<syntaxhighlight lang="javascript" enclose="div">

Revision as of 19:57, 1 February 2012

<noinclude>

For:   audience
Level: level
Time:  N minutes

See more:
    ◾ HowTo Guides

</noinclude>...First line here...

  • Activate the noinclude block so it doesn't appear when Guides are aggregated.
  • audience = Users, Designers, Developers
  • level = Beginner, Intermediate, Advanced
  • N = 1, 2, 5, 10, 15, 20, 30 (minutes)

Heading

Top level heads in HowTo Guides are H3's, so they can be combined into a big PDF, one day.


This code adds a [Custom Print] button to a Form, when placed in an On Load Form Script. In this case, the goal is to restrict a user who has access to that form to a specific template. (The standard Print operation makes all templates available. A standard Action button, meanwhile, is present in every form. This code puts the button in a specific form, to restrict template access for users whose role causes it to be displayed.)

$("#print_button").remove(); 
$("#edit_button").parent().append(
"<input type='button' id='customPrint' value='Custom Print' class='lj-button fg-button ui-state-default ui-corner-all' onClick=\"javascript:lj_printRecord('default_print_layout=template&show_print_layout=no&default_print_document=jsp&default_page_orientation=landscape&default_pdf=yes&show_pdf=no&print_immediately=yes');\">"
);
How it Works
$("#print_button").remove()
Remove the standard print button
$("#edit_button").parent().append
Finds the location of the edit button (present in every form), gets it's parent (the toolbar), and adds the new button to it.
class='lj-button fg-button ui-state-default ui-corner-all'
The standard CSS style elements for platform buttons.
<input type='button' ...
Define the button. (The entire string is one uninterrupted line.)
onClick=\"javascript:lj_printRecord(...
Specify the button's action


Learn more: JavaScript Functions#lj_printRecord