Merging internal table cells dynamically in SAP Adobe forms using Java script code
This blog describes how to merge cells dynamically in a table of SAP Adobe forms.
Customer requirement is to have the table format as per the below screen shot.
Observations from the above requirement:
Depending on which we have to merge the first four table columns (table cells) dynamically..?
Answer:
In the above table, red border indicates that the first four cells are merged...why..?
Answer:
In this case Outcome, Output, Activity and Estimated Completion Date cells are empty.
So, we need to merge all the four cells into a single cell.
Procedure on how to achieve this functionality:
In this requirement I am just giving you a brief overview of Java script coding part involved not the Adobe form table design.
1. After the completion of adobe table design, select the table cell (Outcome cell) as shown below and write the Java script code in the initialize event.
Here is the Java script coding part in the adobe initialize event related to Outcome.
2. Select the table cell (Output cell) as shown below and write the Java script coding in the initialize event.
Here is the Java script coding part in the adobe initialize event related to Output.
Step by step explanation of Java script coding part related to “Outcome”:
Step-1:
Calculate no of rows in a table using the following Java script coding:
My adobe table name: GT_PROJECT
My adobe table body: GT_PROJECT.DATA
Java script syntax to calculate no of rows in a table:
var numrows = xfa.resolveNodes("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA[*]").length;
Step-2:
Loop each row:
for (var i=0; i<numrows; i++)
First take the values from the four cells:
Cell-1 -> Outcome:
outcome = xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].OUTCOME").rawValue;
Cell-2 -> Output:
output = xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].OUTPUT").rawValue;
Cell-3 -> Activity:
activity = xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].ACTIVITY").rawValue;
Cell-4 -> Latest finish / estimated completion:
latfinish = xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].LATEST_FINISH").rawValue;
Step-3:
Use appropriate conditions as required:
if((outcome == null) && (output == null) && (activity == null) && (latfinish == null))
{
xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].OUTCOME").colSpan = "4";
xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].OUTPUT").presence = "hidden";
xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].ACTIVITY").presence = "hidden";
xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].LATEST_FINISH").presence = "hidden";
}
else
{
if (outcome !== null)
{
xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].OUTCOME").colSpan = "3";
xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].OUTPUT").presence = "hidden";
xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].ACTIVITY").presence = "hidden";
}
else
{
xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].OUTCOME").colSpan = "1";
xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].OUTPUT").presence = "visible";
xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].ACTIVITY").presence = "visible";
}
}
delete outcome;
}
Step by step explanation of Java script coding part related to “Output”:
Step-1:
Follow the first two steps as explained above.
Step-2:
Use appropriate conditions as per required:
if (output !== null)
{ xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].OUTPUT").colSpan = "2"; xfa.resolveNode("data.PAGE11.Newtable.#subform[0].GT_PROJECT.DATA["+i+"].ACTIVITY").presence = "hidden";
}
else
{
}
delete output;
Resultant PDF Output:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
10 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |