You are viewing limited content. For full access, please sign in.

Question

Question

Can I hide fields in a Table?

asked on December 3, 2013

 

Is it possible to hide fields in a table based upon a field rule?  Ex...I have  table that has the following: Status, State/Local, County, Municipality, Position, State Agency.  However, when someone choses "State" from the State/Local field, I ONLY want to display State Agency, if they chose "Local" I want the other fields displayed and State Agency hidden.  I've created the rules, but none of the fields get hidden?

Thanks!

0 0

Replies

replied on December 3, 2013

Yes, the field needs to be within the table though, i think.

 

I know I have done this before so it's a matter of trial and error

0 0
replied on December 3, 2013

If you're talking about having dynamic fields show or disappear from the template based on the values selected in a parent field, that's not possible.

replied on December 3, 2013

All my fields are in the table...however, I've not been able to get any of them to hide when I create the rule.

0 0
replied on December 3, 2013

might have to use javascript to test certain fields and use them to hide things

0 0
replied on December 3, 2013

So I've tried numerous methods...I cannot get a field that is part of a table to hide when I create a rule to hide it.  Am I missing something or is this not a function of a field within a table?  This seems like it should be something I can do without having to use Java.

0 0
replied on December 3, 2013

I looked at what i've done in the past, i was able to accomplish this by having hide rules for the page based on fields outside the table. I see it still works so that's your best bet

0 0
replied on December 3, 2013

I'm not following you....could you attached screenshot of your setup?  If you had rules based upon fields "outside the table" then you weren't really hiding any fields in the table??

0 0
replied on December 3, 2013

i was hiding columns

0 0
replied on December 3, 2013

Ok...that's what I'm attempting to do is hide Columns...but inothing is hidden when I create the Rule.  

0 0
replied on December 3, 2013

make sure it's set to hide the column, not just show it under a specific circumstance. 

 

also, as I said, I had the conditions that needed to be met to show or not show the column outside of the table, that's the only way I was able to get it to work.

0 0
replied on December 4, 2013

When field rules are set to show/hide fields within a particular table row, the behavior is a little different. For example, if I have a rule like this:

 

 

When the value in Column 1 is "test," the field in Column 3 is disabled. It is still visible, but I cannot enter any information in it.

 

Actually hiding the field is sort of tricky because it may need to appear for other rows. If you'd like a more visual indication that the field is disabled for the row, you can achieve that with JavaScript. If you let me know what you have in mind, I can probably give you the code to make it work.

 

 

0 0
replied on December 4, 2013

What I'm trying to do is I have Fields in a Table.  They are as follows:

 

Status, State or Local, County, Municipality, Position, State Agency

 

What I'd like to have happen is if they chose "State" from the drop down list, then County, Municipality, and Position are hidden and only State Agency applies.   On the other hand, if they chose "Local" from the drop down list, then I want State Agency hidden.  This is a repeatable table.

 

0 0
replied on December 5, 2013

What you're describing is more complicated than what is currently possible with field rules in Forms. However, you can do it with the following JavaScript. The following code works when you add classes to the affected drop-down fields (to add a class to a field, select it on the Edit page, click Edit, click the Advanced tab, and enter the appropriate classname in the CSS classname field. )

 

  • Add the stateOrLocal class to the State or Local drop-down
  • Add the county class to the County drop-down
  • Add the municipality class to the Municipality drop-down
  • Add the position class to the Position drop-down
  • Add the stateAgency class to the State Agency drop-down

 

Then paste this code into the JavaScript section of the Script page and click Save.

$(document).ready(function () {
    $('.cf-table-block').on('click', function () {

        $('.cf-table-block tbody tr').each(function () {

          if ($(this).find('.stateOrLocal select').children(':selected').text() === "Local")
            {
                $(this).find('.stateAgency select').hide();
                $(this).find('.county select, .municipality select, .position select').show();
            }
            else if ($(this).find('.stateOrLocal select').val() === "State") {
                $(this).find('.county select, .municipality select, .position select').hide();
                $(this).find('.stateAgency select').show();
            }

            else {
                $(this).find('.stateOrLocal select, .county select, .municipality select, .position select').show()
            }
        })
    })
})

 

0 0
replied on July 2, 2014 Show version history

Hi Eric,

 

Thanks for the code, this is very helpful.

 

I am trying to use a modified version of your solution, since I only have a single line field in a table that I wish to hide. There is no condition required for it to hide. Here is the code I am using, however I don't seem to be getting the result I want. I think I'm doing it wrong. My table's class name is CasinoTable and the field class name is auditAmount. Could you please have a look and assist me with the code?

 

$(document).ready(function () {

        $('.CasinoTable tbody tr').each(function () {

                $(this).find('.auditAmount select').hide();

    })
})

Thanks and regards,

Sheldon

0 0
replied on July 2, 2014

Try changing the select to an input:

 

$(document).ready(function () {

        $('.CasinoTable tbody tr').each(function () {

                $(this).find('.auditAmount input').hide();

    })
})

Of course, if you just want to hide these all the time you could do that with CSS. If you want to conditionally hide the field, that's when you'll want to use JavaScript.

 

A CSS rule like .auditAmount input {display:none;} would do the trick for hiding the field all the time.

1 0
replied on July 3, 2014

Hi Eric,

 

Thank you very much for your assistance. I got what I wanted from your CSS rule and it's perfect. The JavaScript, FYI, did not do what was intended.

 

Thank you very much.

 

Regards,

Sheldon

0 0
replied on July 3, 2014 Show version history

Hi,

 

Just as a follow up, I can also hide the column header by referring to its ID as follows

 

#q29 {display: none; } hides the header, which is even better, since only hiding the field still leaves the column header in view.

 

Thanks again

Sheldon

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.