1

SharePoint 2013 では、Data View XSLT Web パーツを使用して、アイテムごとの行数を制限したいと考えています (一般的に返されるアイテムの数ではありません)。div の高さを見つけて行の高さのプロパティで分割するように JavaScript でいくつかの提案をしますが、XSL を使用しているので、他の方法があるのだろうか? CSSでいくつかの解決策も探しましたが、何もありませんでした。

XSLT は次のとおりです (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>

そして、これが結果です:

Lorem Ipsum は、印刷および植字業界の単なるダミー テキストです。Lorem Ipsum は、1500 年代に未知の印刷業者がタイプのギャレーを取り、それをスクランブルしてタイプ見本帳を作成して以来、業界の標準的なダミー テキストでした。それは 5 世紀だけでなく、電子植字への飛躍にも耐え、本質的に変わっていません。1960 年代に Lorem Ipsum のパッセージを含む Letraset シートがリリースされ、最近では Lorem Ipsum のバージョンを含む Aldus PageMaker のようなデスクトップ パブリッシング ソフトウェアで普及しました。

しかし、div の幅を気にせずに最初の 5 行だけを表示したいので、文字制限はここでは機能しません。

4

1 に答える 1