Expression Evaluation Time: ms / Round trip: ms
Custom Paging Control
22. Mar
2013
by Dario Category:
Technical
2

This short blog post shows you how to implement your custom paging control to use with the Composite Web Part.

There is a PageInfo object that you can access when you have enabled paging (PageSize > 0) in the Composite Web Part.

Instead of using the default paging control with <PagingControl/> you can define an expression variable that renders your custom HTML.

public string GetPagingHtml()
{
    IPageInfo pi = (IPageInfo)Expr("PageInfo");

    if (pi.HasMorePages)
    {
        return String.Format("Page {0} - <a href='#' Event='PageLink' StartIndex='{1}'>Next</a>",
            pi.StartIndex / pi.PageSize + 1, pi.StartIndex + pi.PageSize);
    }
    else
    {
        return String.Format("Page {0} - No more pages.", pi.StartIndex / pi.PageSize + 1);
    }
} 

In the FooterTemplate then use {Acme.Paging.GetPagingHtml()} instead of <PagingControl/>.

IPageInfo provides all required information such as StartIndex, RowCount, PageSize etc.

The Composite Web Part does the event binding after each AJAX callback that occurs in event of paging. Therefore you have to add an Event='PageLink' attribute to all the HTML elements that represents a link to page back, forward or jump to a specific page. Further the element needs an attribute StartIndex with the index of the first row of that page.

Comments
TankT72
10.09.2013 01:30
As I understand, this code should be in a Composite User control? I created one - Test.Paging.xml. Pasted the code and used it in the FooterTemplate of the Composite Web Part like this - Test.Paging.GetPagingHtml but I receive an null reference exception. pi is null. I have Pagging enabled and set to 2. What is wrong?
TankT72
11.09.2013 08:40
Ok the problem was with the issue, when number of items is less or equal to a page size. I think this is quite important thing and should be described here.
ABOUT

This blog is about technical and non-technical aspects of the product MatchPoint and other SharePoint topics.

If you would like to post an article or if you have an idea for a post, please contact us.

ARCHIVE
COMMENTS
rganser
07.04.2015 08:57
Hi Tobias,
I works just fine. I overlooked the lin... | Goto Post
Tobias Pfanner
07.04.2015 08:53
Hello Reiner
I tried the download using a 'regular... | Goto Post
rganser
02.04.2015 11:08
When I have a look at the download page for the de... | Goto Post
Patrick Püntener
10.12.2014 03:18
Cool that OWA now is supported! | Goto Post
Markus Wälchli
13.10.2014 12:05
Hi Markus

Somewhat embarassing, but didn't realiz... | Goto Post