|
|
Rank: Enthusiast
Joined: 8/17/2007 Posts: 12
|
Does any body have a example of how can I do paging in a user control with a repeater or with a grid?
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
if it's a .net usercontrol it's just the standard way , but if it's a xslt usercontrol you can't use .net controls here is an example for adding paging to a xslt usercontrol http://tim.netcentric.be/2007/3/23/paging-example.aspx
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 671 Location: Preston, UK
|
Pedro, If you download the code here there is a .net paging control in there and also you can use this one at code project Regards Ismail
Level 2 certified. If it aint broke dont fix.
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 671 Location: Preston, UK
|
Pedro, Here is another one from code projectIsmail
Level 2 certified. If it aint broke dont fix.
|
|
Rank: Fanatic
Joined: 3/15/2007 Posts: 378 Location: Cary, NC USA
|
this one is a variant of Tim's paging (thanks Tim for contributing - great job) that uses numeric paging and eithers a jump to first of last page links if applicable... screenshots and xslt below - for simplicity sake this paging is set to two in this example (only 5 test records total):    and the xslt (note: this code contains a number of items per page property that is set through a passed macro property - you can easily just change this to be the page how many records you want per page - there are also some template and document properties you may need to change as well so just use this as a potential reference or starter code): Code:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp " "> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/> <xsl:variable name="numberOfItemsPerPage" select="/macro/numberOfItemsPerPage"/> <xsl:variable name="pageNumber" > <xsl:choose> <!-- first page --> <xsl:when test="umbraco.library:RequestQueryString('page') <= 0 or string(umbraco.library:RequestQueryString('page')) = '' or string(umbraco.library:RequestQueryString('page')) = 'NaN'">0</xsl:when>
<!-- param passed page --> <xsl:otherwise> <xsl:value-of select="umbraco.library:RequestQueryString('page')"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:template match="/">
<!-- OUTPUT ITEMS START -->
<xsl:variable name="TotalItems" select="count($currentPage/ancestor-or-self::node[@level=1]/descendant::node[@nodeTypeAlias = 'wwLinks']/node)" />
<xsl:variable name="Pages" select="ceiling($TotalItems div $numberOfItemsPerPage)" />
<xsl:for-each select="$currentPage/ancestor-or-self::node[@level=1]/descendant::node[@nodeTypeAlias = 'wwLinks']/node"> <xsl:sort select="@createDate" order="descending"/> <xsl:if test="position() > $numberOfItemsPerPage * number($pageNumber) and position() <= number($numberOfItemsPerPage * number($pageNumber) + $numberOfItemsPerPage ) and string(data [@alias='umbracoNaviHide']) != '1'">
<h2><xsl:value-of select="data [@alias = 'navTitle']"/></h2>
<xsl:value-of select="umbraco.library:LongDate(@createDate)"/><br/>
<xsl:value-of select="data [@alias = 'teaser']"/><br/>
<a title="Visit item: {data [@alias = 'navTitle']}" href="{data [@alias = 'linkURL']}">Visit Now</a> | <a title="View link item: {data [@alias = 'navTitle']}" href="{umbraco.library:NiceUrl(@id)}">Read More</a><br/><br/>
</xsl:if>
</xsl:for-each>
<!-- OUTPUT ITEMS END -->
<!-- PAGING START -->
<xsl:variable name="numFound" select="$TotalItems"/> <xsl:variable name="start" select="1"/> <xsl:variable name="page" select="floor($start div $numberOfItemsPerPage)+1"/>
<xsl:variable name="pages"> <xsl:choose> <xsl:when test="$numFound mod $numberOfItemsPerPage > 0"><xsl:value-of select="floor($numFound div $numberOfItemsPerPage)+1"/></xsl:when> <xsl:otherwise><xsl:value-of select="floor($numFound div $numberOfItemsPerPage)"/></xsl:otherwise> </xsl:choose> </xsl:variable>
Total Items: <xsl:value-of select="$numFound"/><br/>
<!-- ADD FIRST PAGE LINK --> <xsl:if test="number($pageNumber) > 0"> <a href="?page=0"><<</a> </xsl:if>
<!-- ADD PAGING LINKS --> <xsl:choose> <xsl:when test="number($pages) >= 1 "> <xsl:call-template name="loopPages"> <xsl:with-param name="goUntil" select="$pages"/> <xsl:with-param name="currPage" select="$pageNumber"/> <xsl:with-param name="startAt" select="0" /> </xsl:call-template> </xsl:when> </xsl:choose>
<!-- ADD LAST PAGE LINK --> <xsl:if test="number($pageNumber) < number($pages)-1"> <a href="?page={number($pages)-1}">>></a> </xsl:if> <!-- PAGING END -->
</xsl:template>
<!-- PAGING TEMPLATE START -->
<xsl:template name="loopPages">
<xsl:param name="startAt">0</xsl:param> <xsl:param name="goUntil">0</xsl:param> <xsl:param name="currPage">0</xsl:param>
<xsl:if test="number($startAt) < number($goUntil)"> <xsl:choose> <xsl:when test="number($startAt) = number($currPage)"> [ <xsl:value-of select="number($startAt) + 1"/> ] </xsl:when> <xsl:otherwise> [ <a href="?page={number($startAt)}"><xsl:value-of select="number($startAt) + 1"/></a> ] </xsl:otherwise> </xsl:choose> <xsl:call-template name="loopPages"> <xsl:with-param name="startAt" select="$startAt + 1"/> <xsl:with-param name="goUntil" select="$goUntil"/> <xsl:with-param name="currPage" select="$currPage"/> </xsl:call-template> </xsl:if>
</xsl:template>
<!-- PAGING TEMPLATE END -->
</xsl:stylesheet>
|
|
Rank: Enthusiast
Joined: 8/17/2007 Posts: 12
|
My problem was not do the grid or the pager. my problem is how can I get the first 5 pages and the get the next 5 without get all the pages and the choose the pages I what.
1. how can I get the number of childs of a path without using the Document type 2. how can I say I what the firts 5 records and the the next 5 etc...
This using de object model provided by umbraco that's my problem. If e can solve these e quickly can solve the grid with the pager.
I'm new with umbraco and i'm trying to understand the object model. if e can't understant the object model and how can I do things, I will have dificult to understand how to use the XSLT... that's my point of view.
I will look to the file umbraco utilities and then to the XSLT...
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 671 Location: Preston, UK
|
Pedro, The xslt search built by Doug Robar has pagination might be worth looking at that you can get it hereRegards Ismail
Level 2 certified. If it aint broke dont fix.
|
|
Rank: Fanatic
Joined: 3/15/2007 Posts: 378 Location: Cary, NC USA
|
Pedro - I believe Tim's example does not use document types - this may be your best bet: http://tim.netcentric.be/2007/3/23/paging-example.aspxand also if you go the pure .NET route, here's some more articles that may help.... http://msdn2.microsoft.com/en-us/library/aa479347.aspxhttp://www.asp.net/learn/data-access/tutorial-24-vb.aspx
|
|
|
Guest |