1

In SharePoint 2013, using Data View XSLT web part I want to limit the number of rows per item (not the number of items returned in general). I sow a few suggestions in JavaScript to find the div height and divide it in the line height property, but since I'm using XSL I wonder if there is any other way? I also looked for some solutions in CSS but there was nothing there.

Here is the XSLT (I want to limit the number of lines I get from div "AdministrativePosts"):

<Xsl>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema"xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:param name="dvt_apos">&apos;</xsl:param>
<xsl:param name="ManualRefresh"></xsl:param><xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
<xsl:choose>
<xsl:when test="($ManualRefresh = 'True')">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td valign="top">
                        <xsl:call-template name="dvt_1"/>
                    </td>
                    <td width="1%" class="ms-vb" valign="top">
                        <img src="/_layouts/15/images/staticrefresh.gif" id="ManualRefresh" border="0" onclick="javascript: {ddwrt:GenFireServerEvent('__cancel')}" alt="Click here to refresh the dataview."/>
                    </td>
                </tr>
            </table>
        </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="dvt_1"/>
        </xsl:otherwise>
                </xsl:choose>
</xsl:template>

            <xsl:template name="dvt_1">
                <xsl:variable name="dvt_StyleName">Table</xsl:variable>
                <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
                <xsl:variable name="RowLimit" select="1" />
                <div class="AdministrativePosts">                   
                    <xsl:call-template name="dvt_1.body">
                        <xsl:with-param name="Rows" select="$Rows"/>
                        <xsl:with-param name="FirstRow" select="1" />
                        <xsl:with-param name="LastRow" select="$RowLimit" />
                    </xsl:call-template>
            </div>
        </xsl:template>
                <xsl:template name="dvt_1.body">
                    <xsl:param name="Rows"/>
                    <xsl:param name="FirstRow" />
                    <xsl:param name="LastRow" />
                    <xsl:for-each select="$Rows">
                        <xsl:variable name="dvt_KeepItemsTogether" select="false()" />
                        <xsl:variable name="dvt_HideGroupDetail" select="false()" />
                        <xsl:if test="(position() &gt;= $FirstRow and position() &lt;= $LastRow) or $dvt_KeepItemsTogether">
                            <xsl:if test="not($dvt_HideGroupDetail)" ddwrt:cf_ignore="1">
                                <xsl:call-template name="dvt_1.rowview" />
                        </xsl:if>
                    </xsl:if>
                </xsl:for-each>
</xsl:template>
                            <xsl:template name="dvt_1.rowview">     
            <xsl:value-of select="@Body" disable-output-escaping="yes"/>
    </xsl:template>
        </xsl:stylesheet></Xsl>

And this the result:

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

But I want it to show only the first five lines never mind what the width of the div is, so characters limitation will not work here.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Shiri
  • 11
  • 3
  • We can't really help you when you describe a problem without show what the problem is. – ABach Jul 18 '13 at 15:11
  • You've shown the XSLT code, and the actual result. Can you show us the input XML, and the desired result? It's not entirely clear what you mean by "lines" or "rows"; do they mean the same thing? Do you mean you want to limit the number of `` elements being processed? Or do you mean you want to limit the number of lines occupied by the output text after line wrapping? – LarsH Jul 18 '13 at 18:25
  • Yes - I want to limit the number of lines occupied by the output text after line wrapping. I can't show you the input xml, it is rendered by the application, according to a schema. But it takes the data from a SharePoint list (it is like an excel with data). I give one of the fields (columns) a lot of text in the source, but I only want to show part of it. – Shiri Jul 21 '13 at 04:34

0 Answers0