If you’ve ever promoted a field from InfoPath to SharePoint you may have noticed that when working with repeating data you get some different options in the promotion property dialog than if you work with non-repeating data. The additional options are to store your data as First, Last, Count or Merge. First/last will show only the first/last value in the repeating table, count will display the total number of items and merge will take them all and slap them together one after another. The data looks great when you view the columns in a SharePoint list view, breaking each item onto its own line just as you would expect. If you try to work with that same data in a data view web part, however, you’ll notice that it scrunches all of you rows together and eliminates any line breaks.
What we want to do is to go from displaying our column data like this
to this
The key is to rely on the ddwrt XSLT extensions and wrap your selected element with the AutoNewLine function: “ddwrt:AutoNewLine (string(yourelementhere))”. Make sure you typecast it as a string or else you will get nasty xslt transform errors.
The resulting XSLT would look something like this:
<xsl:value-of select="ddwrt:AutoNewLine(string(@_x007b_70e17bba_x002d_be48_x002d_4f3f_x002d_ac0c_x002d_ebe359bebf49_x007d_))" disable-output-escaping="yes" />
MS has a summary of the ddwrt properties available here. Although the article refers to SPS 2003, the properties seem to hold true for WSS 2007 data views as well.
I hope this helps someone out there because there are not many clear references to this on the web that I could find!
2 Comments
Wow – I think this is literally the first site I’ve EVER found with the proper reference to this function! I found it by blind luck; stumbling into it by reviewing the ddwrt namespace functions (for SP2003, same as you…) – then I typed the function into google, and you’re one of the first references. Well done!
Thanks Rob, I’m glad this was useful!