0

我有一个转发器,我通过 Kentico DocumentHelper API(K12 Portal Engine)将数据加载到其中。我可以毫无问题地加载数据,但似乎无法让寻呼机工作/出现。我将该DelayedLoading="true"属性添加到 .ascx 文件中的 CMSRepeater 中。我将 API 用作重构的一部分:

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;
}

旧代码运行良好:

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();
}
4

0 回答 0