1

I want to set DataBindByDefault to false on my repeater because otherwise it makes a call to the db which returns all data from the child nodes of the page which comes to 12MB.

I've hacked it for now and set the Path value to "." (same page only) in the code in front but it's still an extra db call.

So my plan was to set DataBindByDefault to false, assign the data from my custom query to the repeater and then call databind() as follows:

<cms:CMSRepeater ID="repItems" runat="server" Path="."/>

private void InitRepeater()
{
    var data = (DataSet)NewsProvider.GetNews(ClassNames, Path, MaxRelativeLevel, OrderBy, WhereStatement, SelectTopN, -1, -1);
    if (!DataHelper.DataSourceIsEmpty(data))
    {
        repItems.DataSource = data;
        repItems.ControlContext = ControlContext;
        repItems.EnablePaging = true;
        repItems.PageSize = PageSize;
        repItems.PagerControl.CurrentPage = 1;
        repItems.PagerControl.PageSize = PageSize;
        repItems.PagerControl.Visible = false;
        repItems.HideControlForZeroRows = true;
        repItems.TransformationName = Transformation;
        repItems.DataBind();
    }
}

InitRepeater() is called from SetupControl() which called from OnContentLoaded() and ReloadData() but nothing gets rendered.

If I try calling InitRepeater() in PreRender it renders but it ignores the paging settings.

I'm using Kentico v12.0.65

rory
  • 1,490
  • 3
  • 22
  • 50
  • Have you tried specifying in the source of the data the column you really need to limit the size of retrieved data? Eg. just some system columns needed for the transformation methods (NodeAlias, NodeAliasPath, DocumentName, DocumentURLPath) plus the columns you are using in the transformation. Then, I would also try using the LoadPagesIndividually property of the repeater. If true, each page is loaded individually in case of paging. So, this can limit the data size too and they are loaded per page and not all at once. – jurajo Jan 13 '21 at 06:53
  • @jujarp LoadPagesIndividually did the trick. Can you make that an answer so i can mark as correct/accepted please? I always load only the columns I need. That's done in the GetNews method. – rory Jan 13 '21 at 13:05

1 Answers1

1

You should be using the LoadPagesIndividually property of the repeater control. If true, each page is loaded individually in case of paging.

jurajo
  • 937
  • 5
  • 5