Repeating Table to show or hide a section - InfoPath Dev
in

InfoPath Dev

Repeating Table to show or hide a section

Last post 05-14-2007 06:59 PM by Soham Bhatt. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 05-07-2007 12:01 AM

    Repeating Table to show or hide a section

    I have got a repeating table to get the user input on various fields. one of the field have an option (dropdown) with values "yes" & "no". If the user select yes a new section outside the repeating table is shown and if they select no the new section its hidden. It all works fine with first row of the repeating table selected yes. But if i insert any other rows with 1 selected "no"- the section still remains hidden. How can i make it such a way that it only checks one 1 row that is selected yes for which i get to see the section.
    Soham Bhatt
  • 05-07-2007 04:35 AM In reply to

    Re: Repeating Table to show or hide a section

    Hi soham,

    hope I understand your requirement correctly. I guess you have to use code to accomplish what you want. Try the following:

    Add a new text field on your from name it "flag" for example. Use this field for conditional formatting for your new section outside your repeating section. Set the condition to "If flag is not equal to show" then hide this control and delete the conditional formatting you used before. Now double click your dropdown within your repeating section, click data validation, select onafterchange event and click edit code. within your onafterchange use code similar to the one below (jscript):

    if(eventObj.Site.selectSingleNode("../my:NameOfYourDropDownList").text == "Yes")

    {

         XDocument.DOM.selectSingleNode("my:myFields/my:flag").text = "show"

    }

    else

        XDocument.DOM.selectSingleNode("my:myFields/my:flag").text = ""

    Let me know if this helps.

    Listen to Motörhead cos they play Rock'n Roll :)
  • 05-07-2007 06:07 AM In reply to

    Re: Repeating Table to show or hide a section

    Hi Soham,

    I really don't think you need to be using code in this situation. I think what happens is that you are always comparing to the first row of the repeating table. You need to make use of the current() or position() xpath functions. Is the section outside of the first repeating section also repeating? If so, you should compare where position() = current()/position(). If it's not repeating, then you will just look for the existance of ANY node with the value of yes.

    Or a better idea might be to use a master/detail table, and then sort the detail table to only show those that have the "yes" value.

    Either way, please explain the situation a little better so we can provide better support.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-07-2007 06:25 AM In reply to

    Re: Repeating Table to show or hide a section

    Doh ! Yes Matt is right his proposal should be easier to implement than mine. Sometimes you just don't think about the simple things. Thx Matt for jumping in.

    Listen to Motörhead cos they play Rock'n Roll :)
  • 05-07-2007 04:48 PM In reply to

    Re: Repeating Table to show or hide a section

    Thanks Matt and Nukkumatti. I was exactly after the xpath [and also current() and position()] functions to get the results but didn’t the know the way to do it.

    I will try and explain the situation in a better way possible:

    With my Repeating Table I have 4 columns (departure city, arrival city, hotel and car). With hotel and car I have a drop down option of "Yes" and "No".

    Assuming person who fills the form may travel to multiple city hence they can insert more rows and choose the options.

    Case I

    If any row(s) in the repeating table have car option selected "Yes" - a new section (Car Details - non repeating) outside the repeating table appears (until then it was hidden) for user to fill in the details.

    Case II

    If any rows in the repeating table have the Hotel option selected to "yes" a new Repeating table (in a section or just by itself) called Hotel Details is shown (until then it was hidden). The new repeating table/section should have the same number of rows based on the "yes" selected in the previous repeating section. e.g. a person travel 3 trips have 2 rows with hotel selected as "yes" - then the Hotel Details repeating/table section should also show 2 rows.

    Hope this is clear and direct - please provide the steps if possible on how to achieve results for above scenarios.

    Thanks again Guys
    Soham Bhatt
  • 05-07-2007 10:39 PM In reply to

    Re: Repeating Table to show or hide a section

    Hi Soham,

    For Case 1, you will put conditional formatting on the Car Details section that uses THE EXPRESSION = "not(/myfields/Trip/Legs/Leg[ car = 'yes' ])" as the condition, HIDE as the action.  This expression checks for the existance of a node, and then negates it.  Therefore, if there are zero car checks, then that returns false, which is negated to true, and then hides the section.  Conditional formatting is backwards thinking like that.

    For Case 2, I suggest that you make this an optional section within the Leg group given in the XPath above, so that the user will click "Insert Hotel Details" instead of having to check a checkbox and then go to a different part of the form to fill in Hotel Details.  However, if you really want them to be seperate, you will still use a Hotel group within the Leg group, but you will have another instance of the Leg repeating table, but this one will have a Data Filter (double-click the repeating table, and go to Display tab).  The filter will be where hotelCheckBox = 'true'.

     Hope this helps, good luck!

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-14-2007 06:59 PM In reply to

    Re: Repeating Table to show or hide a section

    Hi Matt,

    Thanks for the help again - all works fine except 1 small thing.

    My hotel details are in a repeating section - it has 1st column as a drop down for states from an XML doc (see below) and 2 column is a drop down for Hotels in that state from 1st colum within the same xml doc. It all works fine in the same repeating section after i filter the data in hotel drop down - i''m using cascading drop downs

    But if i insert another hotel detail (repeating section) - the hotel drop down still contains/uses the value from the previous selected repeating hotel detail.

    i have also made a rule for the 1st column to check if the value of its field is not equal to the value in xml.

    What am i missing here?

    sample xml: (having trouble pasting the xml - it strips all the tags out)

    HotelList
    HotelCity value="Adelaide"
    Oaks Horizons
    Oaks Pier Plaza
    HotelCity value="Brisbane"
    Marriott
    Stamford Grand
    Soham Bhatt
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.