Skip to main content

TcxTreeListCustomReportLink.AddPageBreak(TList) Method

Inserts custom page breaks between the tree list’s nodes.

General Description

This method is used in the OnGetCustomPageBreaks event handler.

To enable the OnGetCustomPageBreaks event, set the report link’s OptionsPagination.Custom property to True.

Declaration

procedure AddPageBreak(ANodes: TList); overload;

Parameters

Name Type
ANodes TList

Remarks

Adds a custom page break before the node specified by ANode.

The following example shows how to add a page break before the fifth, tenth and fifteenth node:

//...
procedure TForm1.dxComponentPrinter1Link1GetCustomPageBreaks(
  Sender: TcxTreeListCustomReportLink);
var
  ACount: Integer;
begin
  with Sender, <cxTreeList1> do
  begin
    ACount := AbsoluteVisibleCount - 1;
    if ACount >= 5 then AddPageBreak(AbsoluteVisibleItems[5]);
    if ACount >= 10 then AddPageBreak(AbsoluteVisibleItems[10]);
    if ACount >= 15 then AddPageBreak(AbsoluteVisibleItems[15]);
  end;
end;

The following example shows how to add a page break before each tenth node:

//...
procedure TForm1.dxComponentPrinter1Link1GetCustomPageBreaks(
  Sender: TcxTreeListCustomReportLink);
var
  I: Integer;
begin
  with Sender, <cxTreeList1> do
  begin
    for I := 1 to (AbsoluteVisibleCount - 1) div 10 do
      AddPageBreak(AbsoluteVisibleItems[I * 10]);
  end;
end;
procedure AddPageBreak(const ANodes: array of TcxTreeListNode);

Adds a custom page break by nodes stored in the array specified by ANodes.

The following example shows how to add a page break before specific nodes, available in the tree list’s View:

//...
procedure TForm1.dxComponentPrinter1Link1GetCustomPageBreaks(
  Sender: TcxTreeListCustomReportLink);
const
  FNodeArrayLength = 3;
var
  FNodeArray: array of TcxTreeListNode;
  ACount, AMultiple, I: Integer;
begin
  with Sender, <cxTreeList1> do
  begin
    ACount := AbsoluteVisibleCount - 1;
    AMultiple := Round((ACount - ACount mod FNodeArrayLength)/FNodeArrayLength);
    SetLength(FNodeArray, FNodeArrayLength);
    for I := 0 to FNodeArrayLength - 1 do
      FNodeArray[I] := AbsoluteVisibleItems[AMultiple * (I + 1)];
    AddPageBreak(FNodeArray);
  end;
end;

The following example shows how to place each root level node’s immediate child with its family onto a separate report page:

//...
procedure TcxTreeListRLMainForm.dxComponentPrinterLink1GetCustomPageBreaks(
  Sender: TcxTreeListCustomReportLink);
var
  FNodeArray: array of TcxTreeListNode;
  FRootLevelNode, FRootLevelNodeChild: TcxTreeListNode;
  I, J: Integer;
begin
    for I := 0 to <cxTreeList1>.Count - 1 do
    begin
      FRootLevelNode := <cxTreeList1>.Items[I];
      with FRootLevelNode do
      begin
        if Visible then
        begin
          SetLength(FNodeArray, Count);
          for J := 0 to Count - 1 do
          begin
            FRootLevelNodeChild := Items[J];
            if FRootLevelNodeChild.Visible then
              FNodeArray[J] := FRootLevelNodeChild;
          end;
        end;
      end;
    end;
    Sender.AddPageBreak(FNodeArray);
end;
type
  TcxTreeListNodeArray = array of TcxTreeListNode;
procedure AddPageBreak(const ANodes: TcxTreeListNodeArray);

Adds a custom page break before all the nodes within the array specified by ANodes.

The following example shows how to display each root level node’s immediate child with its family onto a separate report page:

//...
procedure TcxTreeListRLMainForm.dxComponentPrinterLink1GetCustomPageBreaks(
  Sender: TcxTreeListCustomReportLink);
var
  FNodeArray: TcxTreeListNodeArray;
  FRootLevelNode, FRootLevelNodeChild: TcxTreeListNode;
  I, J: Integer;
begin
    for I := 0 to <cxTreeList1>.Count - 1 do
    begin
      FRootLevelNode := <cxTreeList1>.Items[I];
      with FRootLevelNode do
      begin
        if Visible then
        begin
          SetLength(FNodeArray, Count);
          for J := 0 to Count - 1 do
          begin
            FRootLevelNodeChild := Items[J];
            if FRootLevelNodeChild.Visible then
              FNodeArray[J] := FRootLevelNodeChild;
          end;
        end;
      end;
    end;
    Sender.AddPageBreak(FNodeArray);
end;
procedure AddPageBreak(ANodes: TList);

Adds a custom page break before all the nodes within the pointer list specified by ANodes.

The following example shows how to insert a custom page break before each selected node (to enable multiple node selection, set the tree list’s OptionsSelection.MultiSelect property to True):

//...
var
  FNodeList: TList;
//...
  FNodeList := TList.Create;
//...
procedure TForm1.dxComponentPrinter1Link1GetCustomPageBreaks(
  Sender: TcxTreeListCustomReportLink);
begin
  <cxTreeList1>.GetSelections(FNodeList);
  Sender.AddPageBreak(FNodeList);
end;
//...
  FNodeList.Free;
See Also