Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to determine if a table has no body rows?

Avatar

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile
_Bill_Bain_
Level 4

09-12-2008

Our form has a table where the user checks a box to include a product in a table by making the table row visible (otherwise the row is hidden). However, if none of the boxes are checked, I'd like to hide the table so that the header and footer rows aren't visible as well. Is there a way to determine if there are any body rows in a table, since that would tell me whether any product was selected? Does instanceManager only count body rows? Thanks in advance!

Replies

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

611 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

611 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

09-12-2008

Each subform has its own instanceManager so you can get a count of the rows subform if you wish.

Avatar

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile
_Bill_Bain_
Level 4

10-12-2008

So, if for example, the table name were "Table1" and the body rows were "Row1[*], I could use something like:



if(Table1.Row1.instanceManager.count == 0)

Table1.presence = "hidden";



Subforms and tables can be a bit confusing . . . . .

Avatar

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile
_Bill_Bain_
Level 4

10-12-2008

Nope. That didn't work. Even if the table has no body rows, the count reports as 1.

Avatar

Avatar
Validate 1
Level 4
Ryan_Lunka
Level 4

Likes

11 likes

Total Posts

143 posts

Correct Reply

11 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 4
Ryan_Lunka
Level 4

Likes

11 likes

Total Posts

143 posts

Correct Reply

11 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
Ryan_Lunka
Level 4

11-12-2008

Are you sure the repating table row is set to have no Min Count? You could also try to alternative. I've had some problems using the object.instanceManager.method() format. For some reason it won't work for me sometimes. The way that is supposed to be FormCalc, but has always worked for me in JS (I never use FormCalc) is...



Table1._Row1.count == 0



Using the underscore notation is the same as adding .instanceManager and for whatever reason is more consistent in my experience. It's also a bit shorter.



Hope this helps!



Ryan D. Lunka

Cardinal Solutions Group

rlunka@cardinalsolutions.com

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

611 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

611 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

11-12-2008

If there are no rows present then the objects don't exist and accessing the instanceManager is impossible. The _subformName allows access to instanceManager even though the rows do not exist. One looks at the layout dom and one looks at the tempalte dom.

Avatar

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile
_Bill_Bain_
Level 4

11-12-2008

I'm clearly not getting something here -- even with the suggested change, Table1._Row1.count still reports 1 even when all the body rows are set to "hidden". Help!

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

611 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

611 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

11-12-2008

Do you have a min count set?



Also if you want to send your form to livecycle8@gmail.com I can have a look.

Avatar

Avatar
Boost 1
Level 4
Thomas_McConnac
Level 4

Likes

2 likes

Total Posts

134 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 4
Thomas_McConnac
Level 4

Likes

2 likes

Total Posts

134 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
Thomas_McConnac
Level 4

11-12-2008

Hidden only removes them from the layout, it doesn't mean they no longer exist.



You could count all of the body rows and then use an if statement to check if that row's presence is set to visible, then if it is set the table to visible.



pseudo code:

---------

table.presence = "hidden"



for (var i = 0; i < row.count; i++)



{



if row.all.item(i).presence == "visible"



{



table.presence = "visible"



}



}



---------



This will make the table visible if any of the rows are visible. And I would only use this if there is a reason you are setting the row to hidden, instead of making it so the count minimum is 0.



Hope this helps,



Tom

Avatar

11-12-2008

If the count is <= 1, then you could check to see if some required field is null. If it is, then the row must be blank and the table is empty.



I think. 🙂