I have a repeater that I load Data into via the Kentico DocumentHelper API (K12 Portal Engine). I can load the data without any issues but can't seem to get the pager to work/appear. I added the DelayedLoading="true"
attribute to the CMSRepeater in the .ascx file.
I'm using the API as part of a refactor:
protected void SetupControl()
{
if (StopProcessing)
{
RepItems.StopProcessing = true;
}
else
{
InitRepeaterData();
}
}
private void InitRepeaterData()
{
Pager.PageSize = PagingPageSize;
Pager.GroupSize = 4;
Pager.NextPageText = NextButtonText;
Pager.PreviousPageText = PreviousButtonText;
Pager.HidePagerForSinglePage = true;
Pager.DisplayFirstLastAutomatically = true;
Pager.DisplayPreviousNextAutomatically = true;
Pager.PageControl = RepItems.ID;
DataSet data = null;
if (IsLiveSite)
data = CacheHelper.Cache(cs => LoadRepeaterItems(cs), new CacheSettings(10080, "documentlistrollup|" + DocumentContext.CurrentDocument.DocumentCulture + "|" + CurrentPageInfo.NodeAliasPath + "|" + RepItems.ClientID));
else
data = LoadRepeaterItems();
RepItems.DataBindByDefault = false; //also set in the ascx file/markup
RepItems.HideControlForZeroRows = true;
RepItems.EnablePaging = true; //tried with and without
if (!DataHelper.DataSourceIsEmpty(data))
{
RepItems.DataSource = data;
RepItems.UniPagerControl = Pager; //tried with and without
RepItems.DataBind();
//Tried initializing the pager here also
}
else
{
Container.Visible = false;
}
}
private DataSet LoadRepeaterItems(CacheSettings cs = null)
{
var data = DocumentHelper.GetDocuments()
.Types(ClassNames)
.NestingLevel(MaxRelativeLevel)
.TopN(SelectTopN)
.Where(GetWhereCondition(ClassNames))
.Page(Pager.CurrentPage - 1, PagingPageSize)
.InCategories(Category, Category2, Category3)
.Columns(GetSelectedColumns(ClassNames))
.LatestVersion(ShowLatest)
.Path(Path)
.OrderBy(OrderBy)
.FilterDuplicates(true)
.OnCurrentSite();
if (cs != null && cs.Cached)
{
var path = Path.TrimEnd('/', '%');
cs.CacheDependency = CacheHelper.GetCacheDependency(string.Format("node|{0}|{1}|childnodes", SiteContext.CurrentSiteName, path));
}
return data;
}
The old code worked fine:
protected void SetupControl()
{
if (StopProcessing)
{
RepItems.StopProcessing = true;
}
else
{
RepItems.ClassNames = ClassNames;
RepItems.MaxRelativeLevel = MaxRelativeLevel;
RepItems.OrderBy = OrderBy;
RepItems.SelectTopN = SelectTopN;
RepItems.Path = Path;
RepItems.FilterOutDuplicates = true;
RepItems.SelectOnlyPublished = true;
RepItems.SelectedColumns = GetSelectedColumns(ClassNames);
RepItems.WhereCondition = GetWhereCondition(ClassNames);
SetCategories();
Pager.PageSize = PagingPageSize;
Pager.GroupSize = 4;
Pager.NextPageText = NextButtonText;
Pager.PreviousPageText = PreviousButtonText;
Pager.HidePagerForSinglePage = true;
Pager.DisplayFirstLastAutomatically = true;
Pager.DisplayPreviousNextAutomatically = true;
Pager.PageControl = RepItems.ID;
}
RepItems.DataBind();
}