We can use CQWP to show it as ListView,
Refer the below steps:
- Edit ContentQueryMain.xsl file
Search <xsl:template name="OuterTemplate.Body">
Change it as:
<xsl:call-template name="OuterTemplate.CallItemTemplate">
<xsl:with-param name="CurPosition" select="$CurPosition" />
<xsl:with-param name="LastRow" select="$LastRow" /></xsl:call-template>
Search <xsl:template name="OuterTemplate.CallItemTemplate">
- Line 147
You see the "CallItemTemplate". Copy the second line and past it directly beneath it and make it look like this:
<xsl:template name="OuterTemplate.CallItemTemplate"><xsl:param name="CurPosition" /><xsl:param name="LastRow" />
Because we want to use this within our custom item template we also have give the parameter through to the template by adding a when statement just before the within the CallItemTemplate:
<xsl:when test="@Style='SPGrid'"><xsl:apply-templates select="." mode="itemstyle"><xsl:with-param name="CurPos" select="$CurPosition" /><xsl:with-param name="Last" select="$LastRow" /></xsl:apply-templates></xsl:when>
In this statement we specify that it only has to pass-through the parameter when the item template is SPGrid. So our custom template is going to be called “SPGrid”.
Within this file we add our custom xslt item template named "SPGrid".
<xsl:variable name="SafeImageUrl">
<xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
<xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="@Title"/>
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="LinkTarget">
<xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
</xsl:variable>
<xsl:variable name="tableStart">
<xsl:if test="$CurPos = 1">
<![CDATA[
<table width="100%" class="ms-listviewtable" cellpadding="1" cellspacing="0" border="0">
<tr class="ms-viewheadertr ms-vhltr">
<th class="ms-vh-icon"></th>
<th class="ms-vh2">Name</th>
</tr>]]>
</xsl:if>
</xsl:variable>
<xsl:variable name="tableEnd">
<xsl:if test="$CurPos = $Last">
<![CDATA[ </table> ]]>
</xsl:if>
</xsl:variable>
<xsl:value-of select="$tableStart" disable-output-escaping="yes"/>
<tr class="ms-alternating ms-itmhover">
<td class="ms-vb-icon">
<xsl:if test="string-length(@DocumentIconImageUrl) != 0">
<div class="image-area-left">
<img class="image" src="{@DocumentIconImageUrl}" title="" />
</div>
</xsl:if>
</td>
<td class="ms-vb2">
<a href="{$SafeLinkUrl}" title="{@LinkToolTip}"> <xsl:value-of select="$DisplayTitle"/>
</a>
</td>
<td>
<xsl:value-of select="@Title"/>
</td>
</tr>
<xsl:value-of select="$tableEnd" disable-output-escaping="yes"/></xsl:template>
I guess first 3lines for template are not getting added. Please manage and match the code with other templates available in ItemStyle.xsl