[almost there] Repeating table - show header at top of each printed page - InfoPath Dev
in

InfoPath Dev

[almost there] Repeating table - show header at top of each printed page

Last post 10-26-2011 07:58 AM by stara. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 06-19-2011 04:59 PM

    • Skarn
    • Top 50 Contributor
      Male
    • Joined on 04-20-2008
    • Australia
    • Posts 198

    [almost there] Repeating table - show header at top of each printed page

    It's been asked many times how this can be accomplished. And there have been a number of clever methods attempted but I thought there *must* be a simpler way.

    Well I think I have it - Infopath stores the display formatting information for each of its views in XSL files, which are packaged up in the XSN template file.
    XSL files are XML transforms - they are used by Infopath in this case to generate HTML style formatting out of the raw XML data saved in a form and display it.

    Looking at the XSL files in notepad I see that CSS styles appear quite prominently. So I Googles a bit and found that TABLES in HTML can be made up of <THEAD> and <TBODY> tags.
    Inside of Infopath XSL files there are lots of <TBODY> entries for repeating tables, but instead of <THEAD> for table headers, it uses <TBODY class="xdTableHeader"> tags.

    The 'class' attribute here tells Infopath what CSS style to use from those defined at the top of the XSL.

    Well, <THEAD> tag (according to CSS documentation) has a style attribute: style="DISPLAY: table-header-group", which tells a web browser to repeat the header every printed page.

    So after a bit of experimenting I managed to get a template which behaves as we want and I've attached it.

    PROBLEM: As soon as you make any change to the template/table in the design view Infopath turns all the THEADs back into TBODYs!

    So it means that this 'solution' has to be the last thing you do, every time you make a form change - which is to say the least, irritating.

    Here is the process I used to make the modification:

    1. Extract form source files using File > Extract Files or File > Save As Source Files (IP2007)
    2. Go to the extracted files folder
    3. Open up the XSL file corresponding to the View you want to alter the repeating table on in a text editor (Windows Notepad does fine)
    4. Do a Search for <tbody class="xdTableHeader"> - and keep searching until you find the one which is followed by <tr> and <td> tags which match your repeating table headers.
    5. Replace <tbody class="xdTableHeader"> with <thead class="xdTableHeader" style="DISPLAY: table-header-group"
    6. Find the </tbody> closing tag which used to mark the end of the table header <tr> and <td> tags (it's usually right before another <tbody> tag)
    7. Replace that </tbody> tag with </thead>
    8. Save the xsl file

    Now find the xsf file in the extracted files, right-click and design. Go to Preview and insert a ton of rows into your repeating table. Select File > Print Preview and you should see that your table header is repeated on each page that the repeating tabled travels over!

    DON'T make ANY changes to the view layout - as soon as you do Infopath will get rid of all your THEAD work.

    File > Publish your form again to a new location to 'recompile' all the extracted form files back into a single xsn file, this xsn will maintain the THEAD behaviour.

    So what's the next step?
    Well - taking inspiration from Microsofts own DownLevel tools - I think I will build a small script which does all the above for us automatically, eliminating the irritating rework every publish.

    Should I make the script/tool to automate this?

    • Yes please! (0%)
    • Don't bother. (100%)
    • Total Votes: 1
  • 06-19-2011 10:42 PM In reply to

    Re: [almost there] Repeating table - show header at top of each printed page

    Skarn, you simply rock! :)

    Don't forget the xdPreserved for protecting XSLT blocks so that InfoPath Designer doesn't change them on roundtrip. Fun stuff ahead ...

    Patrick Halstead
    Project Manager at Qdabra
  • 06-20-2011 12:31 AM In reply to

    • Skarn
    • Top 50 Contributor
      Male
    • Joined on 04-20-2008
    • Australia
    • Posts 198

    Re: [almost there] Repeating table - show header at top of each printed page

    I can see how the xdPreserved bit (after Googling it) would work to stop Infopath auto-undoing, but I also read xdPreserves is not suitable for use in Browser based forms and the way they are displayed. Browser forms aren't usually in my scope anyway, but if I build a little 'tweak' tool to put <THEAD> tags into the xsl files without using xdPreserved would that allow the tweak to still work in Browser forms do you think?

    I have a few little tools I've built using MSAccess that do various Infopath things, I am thinking I could put all of them into one MSAccess project file and allow people to use whatever they find useful. By automating it, installing little xsl patches into an xsn after each publish would be quick and easy.

  • 06-20-2011 05:06 PM In reply to

    Re: [almost there] Repeating table - show header at top of each printed page

    Mapybe you could create a XSL-"tweaked" XTP that you drag-and-drop into all of your forms...

    Patrick Halstead
    Project Manager at Qdabra
  • 10-26-2011 07:58 AM In reply to

    • stara
    • Top 200 Contributor
    • Joined on 10-19-2010
    • Posts 54

    Re: [almost there] Repeating table - show header at top of each printed page

    Hi,

     Where do I use the xdPreserved element? Can you please provide syntax? Should I include this within: <xsl:stylesheet>?

     

    Thanks in advance

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