on 07-15-2013 9:47 PM
Hello Experts,
I am trying to build a Adobe Form , which displays data using multiple tables . And each table has its own Sub form . I am trying to hide the whole sub form when the table has no records .
Can this only be done by writing a script on the Adobe Form or is there any other way to achieve this ?
I have tried writing different variations of java script to check if the table is empty and change the 'presence' of sub form to 'hidden' . But it does not seem to work .
I would appreciate your help or any code snippet on which can achieve this .
Thanks,
Rohit
Hi Rohit,
In subform properties, during repeating the subform, remove 'Min = 1', if no rows are there in the table, it wont print the subform.
Thanks,
Rakesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am new to adobe form.
But I solved the similar issue using flag which i passed from driver program to form.
In driver program when table has no data I set flag which I pass to form and correspondingly hide subform using JavaScript. I think this least help you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rohit,
I know it's been a while since you opened this thread but I want to help those who come across this topic.
To hide a parent subform if there are no values in a table (rows.count == 0) will work like that:
Let's assume you have a subform called ITEMS on your form. That subform contains, among other elements, a table called ITEMS_CONDITIONS with binding to a table in your interface.
What you have to do now is the following: In the initialize event of the subform ITEMS you enter the following code:
//ITEMS_CONDITIONS is the name of the Table, DATA is the name of the row element
var vRows = ITEMS_CONDITIONS.DATA.all.length;
//then you check how many rows (entries) that table has
//if you have less than 1 entry, you hide the parent element, which is the subform
if (vRows < 1) {
this.parent.presence = "hidden";
}
Hope this will help,
Best Regards,
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Patrick,
I have done the changes as mentioned by you. If the number of entries in the table is greater than or equal to 1, then variable vRows will hold those many entries, but if there are no entries, vRows is not holding any value. Also I have put condition (as mentioned below) to check if it is null but it is also not working.
if (vRows == null)then
*my subform should be hidden;
endif
Can you please let me know your views on this.
Regards
Mini
In my case, the driver program are SAP Standard programs, so to set the Dynamic flag as 'X'(even in debugger) will be time consuming process.
The role of the Pop-up used by you is to check the value of the variable IMTEST. I have already done the same thing by holding the count of records of the table in a text field (Date) i.e. temporarily created in the form. Below code indicates the same:
var count = $.resolveNodes("Comprehensive[*]").length;
$.parent.parent.parent.Date = count;
Text Field is showing the count if it is >=1 but not for 0.
Check below,
IMTEST.IsNull
also check your if condition syntax
also refer IS THAT FIELD EMPTY
Hope this helps
Hi Prajesh,
I have debugged the standard program also and set the dynamic flag as well. I have done the Scripting using Javascript (to hide the subform if a table present in this subform has no no records) and this script is working.
The only issue that I am facing now is when I am displaying the number of records of the table in the pop-up, it is not getting displayed . Please find below the code for your reference:
xfa.host.messageBox(COUNT);
But when display the pop up with just a message e.g Welcome, it gets dispalyed.Can you please let me know what could be the issue.
Regards
Mini
Try below, COUNT is integer type variable, and method messageBox required a string type parameter so you need to convert into string.
xfa.host.messageBox(COUNT.toString());
or
xfa.host.messageBox("Count :" + COUNT);
Hope this helps.
Also open a new thread for this issue, so it's helps to others also.
Hi Prajesh,
Can you please let me know your views on the below query:
I have a subform1 which includes some 4-5 subforms (let us say child subforms). Each child subform has a Text and its value (Text field). We have written individual scripts to hide child subform if there is not value in the Text field. But we need to hide the outermost subform i.e subform1 if all its child subforms do not hold any value. We can do this by checking respective text fields of child subform but in this case we have to write number of script lines.
Is there any other way that we can do this.
Regards
Mini
Hi Rohit,
It's late, but maybe, my response will serve.
It's for second point issue : The adobe form is skipping the first row of the internal table and displaying the rest of the rows..
It may comes of the binding tab of your table.
You have to check it again, perhaps in the subform of the table, your binding is made with a record of the table and not with the table itself.
So ADOBE reads your first record, and when binding of the bodyrow subform it reads the next one.
christian.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rakesh,
Removing the "Min = 1 " is working when rows are not in the table . But now i am encountering a weird problem when the table has rows in it.
The adobe form is skipping the first row of the internal table and displaying the rest of the rows.
Currently I have the binding of the sub-form set as
$record.itab2.DATA[*]
and Repeat subform for each data item is checked with Min and Max unchecked.
Any advise or help is appreciated.
Thanks,
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rohit,
Can you try this? Assign the Min = 1 back, and wrap your table into a subform, say subform A.
Under initialize event of subform A, put this coding. formcalc script, run at client side
if ( $record.itab2.DATA[*] == null ) then
this.presence = "hidden"
else
this.presence = "visible"
endif
regards,
Xiang Li
Hi Rohit
I used formCalc and it works fine
the code I used (in the form:ready event of the subform):
if ( $.table.row.count == 0 ) then
$.presence = "hidden"
endif
About the first row missing:
it looks like you are not using a wrapper for your rows,
the meaning is that you need to build the PDFSource node with the following hirarchy
table node with cardinality 1 to 1 -> wrapper node with cardinality 0 to n -> data node with cardinality 0 to 1 with an attribute for each colomn.
then set the binding of the table to the table node,
the binding of the row to the wrapper node (don't forget to sign the repeat row for each data item checkbox),
and the binding for each cell to the attributes of the data node.
withoute using the wrapper the first row of the table is 'taken' for the row binding.
the subform needs no binding.
hope I helped
Shai
Hi Rohit,
If you have placed the subform in Design page:Try to use the below FormCalc in event: formready
Assuming that you have 5 rows in the table and want to validate each row……
If ($.parent.row1 == null ) and
($.parent.row2 == null and
($.parent.row3 == null and
($.parent.row4 == null and
($.parent.row5 == null ) then
$.presence = “hidden”
Else
$.presence = “visible”
If you have placed the subform in Master page:Try to use the above FormCalc in event: layoutready
Hope it works!
Naveen
Hi Rohit,
These are the formcalc scripting ..
this.presence = "visible"
this.presence = "hidden"
Using javascript, you need to be very careful on the way you write the code. example make sure there is semicolons as statement terminators, etc.
Do you mind to paste your code here on the condition how you check if there is data in the table , how you make the subform visible/hidden, and which event you put your code in.
Thanks.
regards,
Xiang Li
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.