Customazing XsltListViewWebPart XSL with pagination


/ Published in: XSLT
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <WebPartPages:XsltListViewWebPart runat="server" Description="" PartOrder="0" Default="FALSE" HelpLink="" AllowRemove="True" IsVisible="True" AllowHide="True" UseSQLDataSourcePaging="True" ExportControlledProperties="False" IsIncludedFilter="" DataSourceID="" Title="Pages" ViewFlag="8" NoDefaultStyle="TRUE" AllowConnect="True" DisplayName="Pages" CacheXslStorage="False" FrameState="Normal" PageSize="-1" PartImageLarge="" AsyncRefresh="False" ExportMode="NonSensitiveData" Dir="Default" DetailLink="" ShowWithSampleData="False" ListId="27c97b8d-fdb8-4c29-9ae4-9f2ab1be38f4" ListName="{27C97B8D-FDB8-4C29-9AE4-9F2AB1BE38F4}" FrameType="None" PartImageSmall="" IsIncluded="True" SuppressWebPartChrome="False" AllowEdit="True" ViewGuid="" ChromeType="None" AutoRefresh="False" AutoRefreshInterval="60" AllowMinimize="True" WebId="00000000-0000-0000-0000-000000000000" ViewContentTypeId="0x" InitialAsyncDataFetch="False" GhostedXslLink="main.xsl" MissingAssembly="Cannot import this Web Part." HelpMode="Modeless" ID="g_5b9fdc05_4e2f_438a_a9c3_d08b3a379b94" ConnectionID="00000000-0000-0000-0000-000000000000" AllowZoneChange="True" ManualRefresh="False" __designer:customxsl="fldtypes_Ratings.xsl" __MarkupType="vsattributemarkup" __WebPartId="{5B9FDC05-4E2F-438A-A9C3-D08B3A379B94}" __AllowXSLTEditing="true" WebPart="true" Height="" Width=""><ParameterBindings>
  2. <ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/>
  3. <ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/>
  4. <ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
  5. <ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)"/>
  6. <ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)"/>
  7. <ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)"/>
  8. <ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)"/>
  9. <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)"/>
  10. <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(core,noXinviewofY_DEFAULT)"/>
  11. <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)"/>
  12. <ParameterBinding Name="MoreAnnouncements" Location="Resource(wss,moreItemsParen)"/>
  13. <ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
  14. </ParameterBindings>
  15. <XmlDefinition>
  16. <View Name="{1282C8BA-2702-4C55-A29B-EE5D5A70966E}" MobileView="TRUE" Type="HTML" DisplayName="All Documents" Url="/Pages/Forms/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/dlicon.png" TabularView="FALSE">
  17. <Query/>
  18. <ViewFields>
  19. <FieldRef Name="Title"/>
  20. <FieldRef Name="Created"/>
  21. <FieldRef Name="PublishingPageContent"/>
  22. </ViewFields>
  23. <RowLimit Paged="TRUE">5</RowLimit>
  24. <Toolbar Type="Standard"/>
  25. <ViewStyle ID="16"/>
  26. </View>
  27. </XmlDefinition>
  28. <DataFields>
  29. </DataFields>
  30. <xsl>
  31.  
  32.  
  33. <xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
  34. version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
  35. xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer"
  36. xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  37. xmlns:sharepoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal"
  38. xmlns:o="urn:schemas-microsoft-com:office:office" ddwrt:ghost="show_all">
  39. <xsl:include href="/_layouts/xsl/main.xsl" />
  40. <xsl:include href="/_layouts/xsl/internal.xsl" />
  41. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
  42. <xsl:output method='html' indent='yes' />
  43.  
  44.  
  45. <xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
  46. xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer"
  47. xmlns:sharepoint="Microsoft.SharePoint.WebControls" xmlns:o="urn:schemas-microsoft-com:office:office"
  48. ddwrt:ghost="" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">
  49. <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[$EntityName = '' or (position() &gt;= $FirstRow and position() &lt;= $LastRow)]" />
  50. <table cellpadding="10" cellspacing="0" border="1" style="padding:25px;">
  51. <tr>
  52. <td colspan='2'>
  53. <b style="font-size:25px;">Friend's List</b>
  54. </td>
  55. </tr>
  56. <xsl:for-each select="$Rows">
  57. <xsl:call-template name="RowView">
  58. </xsl:call-template>
  59. </xsl:for-each>
  60. <tr>
  61. <td colspan="2"><xsl:call-template name="pagingButtons" /></td>
  62. </tr>
  63. </table>
  64. </xsl:template>
  65.  
  66. <xsl:template name="RowView">
  67. <xsl:variable name="thisNode" select="." />
  68. <tr>
  69. <td align="center">
  70. <img style="height:100px;border:5px solid #888;">
  71. <xsl:attribute name="src">
  72. <xsl:value-of select="@Picture"></xsl:value-of>
  73. </xsl:attribute>
  74.  
  75. <xsl:attribute name="alt">
  76. <xsl:value-of select="@Title"></xsl:value-of>
  77. </xsl:attribute>
  78.  
  79. </img>
  80. </td>
  81. <td valign="top">
  82. <b>Name : </b>
  83. <xsl:value-of select="@Title"></xsl:value-of>
  84. <br></br>
  85. <b>Email : </b>
  86. <xsl:value-of select="@Email" disable-output-escaping="yes"></xsl:value-of>
  87. <br></br>
  88. <b>Address :</b>
  89. <br></br>
  90. <xsl:value-of select="@Address" disable-output-escaping="yes"></xsl:value-of>
  91. </td>
  92. </tr>
  93. </xsl:template>
  94.  
  95. <xsl:template name="pagingButtons">
  96. <xsl:choose>
  97. <xsl:when test="$XmlDefinition/List/@TemplateType = 106 and $XmlDefinition/@RecurrenceRowset='TRUE'">
  98. <xsl:if test="$dvt_nextpagedata or $dvt_prevpagedata">
  99. <xsl:call-template name="CalendarExpandedRecurrenceFooter"/>
  100. </xsl:if>
  101. </xsl:when>
  102. <xsl:otherwise>
  103. <xsl:if test="$XmlDefinition/RowLimit[@Paged='TRUE']">
  104. <xsl:call-template name="CommandFooter">
  105. <xsl:with-param name="FirstRow" select="$FirstRow" />
  106. <xsl:with-param name="LastRow" select="$LastRow" />
  107. <xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" />
  108. </xsl:call-template>
  109. </xsl:if>
  110. </xsl:otherwise>
  111. </xsl:choose>
  112. </xsl:template>
  113. <xsl:template name="CommandFooter">
  114. <xsl:param name="FirstRow" select="1"/>
  115. <xsl:param name="LastRow" select="1"/>
  116. <xsl:param name="dvt_RowCount" select="1"/>
  117. <xsl:if test="$FirstRow &gt; 1 or $dvt_nextpagedata">
  118. <xsl:call-template name="Navigation">
  119. <xsl:with-param name="FirstRow" select="$FirstRow" />
  120. <xsl:with-param name="LastRow" select="$LastRow" />
  121. <xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" />
  122. </xsl:call-template>
  123. </xsl:if>
  124. </xsl:template><xsl:template name="Navigation">
  125. <xsl:param name="FirstRow" select="1"/>
  126. <xsl:param name="LastRow" select="1"/>
  127. <xsl:param name="dvt_RowCount" select="1"/>
  128. <xsl:variable name="LastRowValue">
  129. <xsl:choose>
  130. <xsl:when test="$EntityName = '' or $LastRow &lt; $RowTotalCount">
  131. <xsl:value-of select="$LastRow"/>
  132. </xsl:when>
  133. <xsl:otherwise>
  134. <xsl:value-of select="$RowTotalCount"/>
  135. </xsl:otherwise>
  136. </xsl:choose>
  137. </xsl:variable>
  138. <xsl:variable name="NextRow">
  139. <xsl:value-of select="$LastRowValue + 1"/>
  140. </xsl:variable>
  141. <table id="bottomPagingCell{$WPQ}" style="font-size:25px;width:100%;padding:5px;" border="0">
  142. <tr>
  143. <td style="width:50%">
  144. <xsl:if test="$dvt_firstrow &gt; 1">
  145. <a>
  146. <xsl:choose>
  147. <xsl:when test="$dvt_RowCount = 0 and not($NoAJAX)">
  148. <xsl:attribute name="onclick">javascript:RefreshPageTo(event, "<xsl:value-of select="$PagePath"/>?<xsl:value-of select="$ShowWebPart"/>\u0026<xsl:value-of select='$FieldSortParam'/><xsl:value-of select='$SortQueryString'/>\u0026View=<xsl:value-of select="$View"/>");javascript:return false;</xsl:attribute>
  149. <xsl:attribute name="href">javascript:</xsl:attribute>
  150. <img src="/_layouts/{$LCID}/images/prev.gif" border="0" alt="{$Rows/@idRewind}" />
  151. <img src="/_layouts/{$LCID}/images/prev.gif" border="0" alt="{$Rows/@idRewind}" />
  152. </xsl:when>
  153. <xsl:otherwise>
  154. <xsl:variable name="RealRowLimit">
  155. <xsl:choose>
  156. <xsl:when test="$XmlDefinition/Query/GroupBy[@Collapse='TRUE']/@GroupLimit">
  157. <xsl:value-of select ="$XmlDefinition/Query/GroupBy[@Collapse='TRUE']/@GroupLimit"/>
  158. </xsl:when>
  159. <xsl:otherwise>
  160. <xsl:value-of select = "$XmlDefinition/RowLimit"/>
  161. </xsl:otherwise>
  162. </xsl:choose>
  163. </xsl:variable>
  164. <xsl:choose>
  165. <xsl:when test="not($NoAJAX)">
  166. <xsl:attribute name="onclick">javascript:RefreshPageTo(event, "<xsl:value-of select="$PagePath"/>?<xsl:value-of select="$dvt_prevpagedata"/><xsl:value-of select="$ShowWebPart"/>\u0026PageFirstRow=<xsl:value-of select="$FirstRow - $RealRowLimit"/>\u0026<xsl:value-of select='$FieldSortParam'/><xsl:value-of select='$SortQueryString'/>\u0026View=<xsl:value-of select="$View"/>");javascript:return false;</xsl:attribute>
  167. <xsl:attribute name="href">javascript:</xsl:attribute>
  168. </xsl:when>
  169. <xsl:otherwise>
  170. <xsl:attribute name="href">
  171. javascript: <xsl:call-template name="GenFireServerEvent">
  172. <xsl:with-param name="param" select="concat('dvt_firstrow={',$FirstRow - $XmlDefinition/RowLimit,'};dvt_startposition={',$dvt_prevpagedata,'}')"/>
  173. </xsl:call-template>
  174. </xsl:attribute>
  175. </xsl:otherwise>
  176. </xsl:choose>
  177. <img src="/_layouts/{$LCID}/images/prev.gif" border="0" alt="{$Rows/@idPrevious}" />Pre
  178. </xsl:otherwise>
  179. </xsl:choose>
  180. </a>
  181. </xsl:if>
  182. </td>
  183.  
  184. <td style="width:50%" align="right">
  185. <xsl:if test="$LastRowValue &lt; $dvt_RowCount or string-length($dvt_nextpagedata)!=0">
  186.  
  187. <a>
  188. <xsl:choose>
  189. <xsl:when test="not($NoAJAX)">
  190. <xsl:attribute name="onclick">javascript:RefreshPageTo(event, "<xsl:value-of select="$PagePath"/>?<xsl:value-of select="$dvt_nextpagedata"/><xsl:value-of select="$ShowWebPart"/>\u0026PageFirstRow=<xsl:value-of select="$NextRow"/>\u0026<xsl:value-of select='$FieldSortParam'/><xsl:value-of select='$SortQueryString'/>\u0026View=<xsl:value-of select="$View"/>");javascript:return false;</xsl:attribute>
  191. <xsl:attribute name="href">javascript:</xsl:attribute>
  192. </xsl:when>
  193. <xsl:otherwise>
  194. <xsl:attribute name="href">javascript: <xsl:call-template name="GenFireServerEvent">
  195. <xsl:with-param name="param" select="concat('dvt_firstrow={',$NextRow,'};dvt_startposition={',$dvt_nextpagedata,'}')"/>
  196. </xsl:call-template>
  197. </xsl:attribute>
  198. </xsl:otherwise>
  199. </xsl:choose>
  200. Next<img src="/_layouts/{$LCID}/images/next.gif" border="0" alt="{$Rows/@tb_nextpage}" />
  201. </a>
  202. </xsl:if>
  203. </td>
  204. </tr>
  205. </table>
  206.  
  207. <xsl:if test="not($GroupingRender)">
  208. var topPagingCell = document.getElementById(&quot;topPagingCell<xsl:value-of select="$WPQ" />&quot;);
  209. var bottomPagingCell = document.getElementById(&quot;bottomPagingCell<xsl:value-of select="$WPQ" />&quot;);
  210. if (topPagingCell != null &amp;&amp; bottomPagingCell != null)
  211. {
  212. topPagingCell.innerHTML = bottomPagingCell.innerHTML;
  213. }
  214. </script>
  215. </xsl:if>
  216. </xsl:template>
  217. </xsl:stylesheet>
  218.  
  219.  
  220.  
  221.  
  222.  
  223. </xsl></WebPartPages:XsltListViewWebPart>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.