Custom Paging Control
Date: 22.03.2013
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.