Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > UniView Total Nunber of Items for custom pagination display View modes: 
User avatar
Member
Member
dotnetdave-dotnetdave - 1/6/2012 9:58:32 AM
   
UniView Total Nunber of Items for custom pagination display
I am using the hierarchical viewer to display a list of notes from the content tree. I need to do pagination and show the number of records on the page ie
Displaying 21 - 30 of 100
I have used a repeater before and displayed this using
  PagingText.Text = string.Format(
"<p class=\"itemcount\"> Displaying {0} - {1} of {2}</p>",
repItems.PagerControl.RecordStart,
repItems.PagerControl.RecordEnd,
repItems.PagerControl.TotalRecords);


How can I do this using the univiewer and its unipager control?

User avatar
Member
Member
Dave Smith - 1/6/2012 10:11:12 AM
   
RE:UniView Total Nunber of Items for custom pagination display
Oops used my old account

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 1/6/2012 12:36:36 PM
   
RE:UniView Total Nunber of Items for custom pagination display
This seems to work:

int RecordStart = 0;
int RecordEnd = 0;
if (uniView.PagerControl.CurrentPage == 1)
{
RecordStart = 1;
if (uniView.PagerControl.DataSourceItemsCount <= uniView.PagerControl.PageSize)
{
RecordEnd = uniView.PagerControl.ItemsCount;
}
else
{
RecordEnd = uniView.PagerControl.PageSize;
}
}
else if (uniView.PagerControl.CurrentPage == uniView.PagerControl.PageCount)
{
RecordEnd = uniView.PagerControl.DataSourceItemsCount;
RecordStart = RecordEnd - (int)(((decimal)uniView.PagerControl.DataSourceItemsCount%(uniView.PagerControl.PageSize))-1);
}
else
{
RecordEnd = (uniView.PagerControl.CurrentPage * uniView.PagerControl.PageSize);
RecordStart = RecordEnd - (uniView.PagerControl.PageSize - 1);

}
PagingText.Text = String.Format("Showing {0} - {1} of {2}", RecordStart, RecordEnd, uniView.PagerControl.DataSourceItemsCount);


I added it to the PreRender event handler

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 1/6/2012 12:37:56 PM
   
RE:UniView Total Nunber of Items for custom pagination display
Slight edit.


int RecordStart = 0;
int RecordEnd = 0;
if (uniView.PagerControl.CurrentPage == 1)
{
RecordStart = 1;
if (uniView.PagerControl.DataSourceItemsCount <= uniView.PagerControl.PageSize)
{
RecordEnd = uniView.PagerControl.DataSourceItemsCount;
}
else
{
RecordEnd = uniView.PagerControl.PageSize;
}
}
else if (uniView.PagerControl.CurrentPage == uniView.PagerControl.PageCount)
{
RecordEnd = uniView.PagerControl.DataSourceItemsCount;
RecordStart = RecordEnd - (int)(((decimal)uniView.PagerControl.DataSourceItemsCount%(uniView.PagerControl.PageSize))-1);
}
else
{
RecordEnd = (uniView.PagerControl.CurrentPage * uniView.PagerControl.PageSize);
RecordStart = RecordEnd - (uniView.PagerControl.PageSize - 1);

}
PagingText.Text = String.Format("Showing {0} - {1} of {2}", RecordStart, RecordEnd, uniView.PagerControl.DataSourceItemsCount);