Hiding tables using xsl:when - InfoPath Dev
in

InfoPath Dev

Hiding tables using xsl:when

Last post 03-04-2008 09:28 AM by Greg Collins. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 02-07-2008 08:35 PM

    Hiding tables using xsl:when

    I'm trying to use "xsl:when" to hide a format table that has a repeating table in it. Basically I want to use a checkbox to show or hide the format table. The code I added to the .xsl file works just fine to show/hide the table but when I close the form and open it back up, the repeating table elements become unbound. I know I can put it in a section but I just don't like how it gets indented. If anyone know what I'm doing wrong, please let me know. Thanks!

    The code I added to the view is just below the first <div> tag. It's the xsl:attribute, xsl:choose, and xsl:when tags.

    <div>

    <xsl:attribute name="style">

    <xsl:choose>

    <xsl:when test="my:grpSummary/my:txtPriceType = &quot;Gate&quot;">display: none;</xsl:when>

    </xsl:choose>

    </xsl:attribute>

    <table class="xdFormLayout xdLayout" style="TABLE-LAYOUT: fixed; WIDTH: 656px; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-COLLAPSE: collapse; WORD-WRAP: break-word; BORDER-BOTTOM-STYLE: non" width="undefined" border="1" tabIndex="-1">

    <colgroup>

    <col style="WIDTH: 656px"></col>

    </colgroup>

    <tbody vAlign="top">

    <tr class="primaryVeryDark" style="MIN-HEIGHT: 25px">

    <td style="BORDER-RIGHT: #626262 1pt solid; PADDING-RIGHT: 1px; BORDER-TOP: #626262 1pt solid; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; VERTICAL-ALIGN: middle; BORDER-LEFT: #626262 1pt solid; PADDING-TOP: 1px; BORDER-BOTTOM: #ece9d8 6pt; BACKGROUND-COLOR: #626262">

    <div align="center">

    <font face="Calibri" color="#ffffff">

    <strong>Related To</strong>

    </font>

    </div>

    </td>

    </tr>

    <tr class="primarylight" style="MIN-HEIGHT: 0.313in">

    <td vAlign="top" style="BORDER-RIGHT: #626262 1pt solid; BORDER-TOP: #ece9d8 6pt; BORDER-LEFT: #626262 1pt solid; BORDER-BOTTOM: #626262 1pt solid; TEXT-ALIGN: left">

    <div>

    <table class="xdRepeatingTable msoUcTable" title="" style="TABLE-LAYOUT: fixed; WIDTH: 652px; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-COLLAPSE: collapse; WORD-WRAP: break-word; BORDER-BOTTOM-STYLE: non" border="1" xd:CtrlId="CTRL165">

    <colgroup>

    <col style="WIDTH: 43px"></col>

    <col style="WIDTH: 121px"></col>

    <col style="WIDTH: 87px"></col>

    <col style="WIDTH: 99px"></col>

    <col style="WIDTH: 113px"></col>

    <col style="WIDTH: 105px"></col>

    <col style="WIDTH: 84px"></col>

    </colgroup>

    <tbody class="xdTableHeader">

    <tr>

    <td>

    <div>

    <strong>Txt RID</strong>

    </div>

    </td>

    <td>

    <div>

    <strong>Txt RCustomer Code</strong>

    </div>

    </td>

    <td>

    <div>

    <strong>Txt RProfile No</strong>

    </div>

    </td>

    <td>

    <div>

    <strong>Txt RWaste Name</strong>

    </div>

    </td>

    <td>

    <div>

    <strong>Txt REffective Date</strong>

    </div>

    </td>

    <td>

    <div>

    <strong>Txt RCurrent Price</strong>

    </div>

    </td>

    <td>

    <div>

    <strong>Dec RNew Price</strong>

    </div>

    </td>

    </tr>

    </tbody><tbody xd:xctname="RepeatingTable">

    <xsl:for-each select="my:grpRelated/my:rptRelated">

    <tr>

    <td><span class="xdTextBox" hideFocus="1" title="" tabIndex="0" xd:xctname="PlainText" xd:CtrlId="CTRL166" xd:binding="my:txtRID" style="WIDTH: 100%">

    <xsl:value-of select="my:txtRID"/>

    </span>

    </td>

    <td><span class="xdTextBox" hideFocus="1" title="" tabIndex="0" xd:xctname="PlainText" xd:CtrlId="CTRL167" xd:binding="my:txtRCustomerCode" style="WIDTH: 100%">

    <xsl:value-of select="my:txtRCustomerCode"/>

    </span>

    </td>

    <td><span class="xdTextBox" hideFocus="1" title="" tabIndex="0" xd:xctname="PlainText" xd:CtrlId="CTRL168" xd:binding="my:txtRProfileNo" style="WIDTH: 100%">

    <xsl:value-of select="my:txtRProfileNo"/>

    </span>

    </td>

    <td><span class="xdTextBox" hideFocus="1" title="" tabIndex="0" xd:xctname="PlainText" xd:CtrlId="CTRL169" xd:binding="my:txtRWasteName" style="WIDTH: 100%">

    <xsl:value-of select="my:txtRWasteName"/>

    </span>

    </td>

    <td><span class="xdTextBox" hideFocus="1" title="" tabIndex="0" xd:xctname="PlainText" xd:CtrlId="CTRL170" xd:binding="my:txtREffectiveDate" style="WIDTH: 100%">

    <xsl:value-of select="my:txtREffectiveDate"/>

    </span>

    </td>

    <td><span class="xdTextBox" hideFocus="1" title="" tabIndex="0" xd:xctname="PlainText" xd:CtrlId="CTRL171" xd:binding="my:txtRCurrentPrice" style="WIDTH: 100%">

    <xsl:value-of select="my:txtRCurrentPrice"/>

    </span>

    </td>

    <td><span class="xdTextBox xdBehavior_Formatting" hideFocus="1" title="" contentEditable="true" tabIndex="0" xd:xctname="PlainText" xd:CtrlId="CTRL172" xd:boundProp="xd:num" xd:binding="my:decRNewPrice" xd:datafmt="&quot;number&quot;,&quot;numDigits:auto;negativeOrder:1;&quot;" style="WIDTH: 100%">

    <xsl:attribute name="xd:num">

    <xsl:value-of select="my:decRNewPrice"/>

    </xsl:attribute>

    <xsl:choose>

    <xsl:when test="function-available('xdFormatting:formatString')">

    <xsl:value-of select="xdFormatting:formatString(my:decRNewPrice,&quot;number&quot;,&quot;numDigits:auto;negativeOrder:1;&quot;)"/>

    </xsl:when>

    <xsl:otherwise>

    <xsl:value-of select="my:decRNewPrice"/>

    </xsl:otherwise>

    </xsl:choose>

    </span>

    </td>

    </tr>

    </xsl:for-each>

    </tbody>

    </table>

    <div class="optionalPlaceholder" xd:xmlToEdit="rptRelated_40" tabIndex="0" xd:action="xCollection::insert" style="WIDTH: 652px">Insert item</div>

    </div>

    </td>

    </tr>

    </tbody>

    </table>

    </div>

    Shaun Nieves
    Sharepoint Manager
  • 02-22-2008 12:01 PM In reply to

    Re: Hiding tables using xsl:when

    Manual edits to the XSL is a bad idea. InfoPath provides a means of writing your own XSL (if absolutely necessary) using a Preserve Code Block -- but even though IP is not supposed to touch your code in the PCB, it still sometimes does. There's another way to make a manually generated XSL into a view (editing from within InfoPath is not supported) but these are for extreme cases. Yours is not.

    The solution to your problem is what you are trying to avoid: The Section.

    The indention problem is only a matter of not knowing where to look. There's two places you need to go to fix the issue.

    1. Section Properties: Set all the padding and margin values to zero.
    2. Borders: Remove the default 1pt WHITE border from the section.

    Now you should have a sectoin with no indention.

  • 03-03-2008 03:44 PM In reply to

    Re: Hiding tables using xsl:when

    Ack! I can't believe it was that easy! Thanks a lot!

    Shaun Nieves
    Sharepoint Manager
  • 03-04-2008 09:28 AM In reply to

    Re: Hiding tables using xsl:when

    Yeah, that bites a lot of people. I made a request to the InfoPath team to default to no border and zeros for margin and padding, but they wouldn't go for it. So, you just have to make sure you fix those every time you insert a new section. It's the first thing I do.

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.