Skip to main content
All docs
V24.2

DxTreeList.GetPageCount() Method

Returns the total number of pages in the TreeList.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public int GetPageCount()

Returns

Type Description
Int32

The total number of pages.

Remarks

The TreeList automatically calculates the number of pages required to show all rows. The PageSize property specifies the maximum number of rows displayed on a page. Users can change the page size at runtime if you display the page size selector. The page count also changes when users expand/collapse nodes or filter data.

Call the GetPageCount method to get the total number of TreeList pages.

The following example expands all nodes, determines the number of pages in the TreeList, then navigates to the last page. These actions take place when the TreeList is rendered for the first time.

@inject EmployeeTaskService EmployeeTaskService

<DxTreeList @ref="MyTreeList"
            Data="TreeListData"
            KeyFieldName="Id"
            ParentKeyFieldName="ParentId"
            AutoExpandAllNodes="true"
            @bind-PageIndex="@PageIndex">
    <Columns>
        <DxTreeListDataColumn FieldName="Name" Caption="Task" />
        <DxTreeListDataColumn FieldName="EmployeeName" />
        <DxTreeListDataColumn FieldName="StartDate" />
        <DxTreeListDataColumn FieldName="DueDate" />
    </Columns>
</DxTreeList>


@code {
    List<EmployeeTask> TreeListData { get; set; }
    ITreeList MyTreeList { get; set; }
    int PageIndex { get; set; }

    protected override void OnInitialized() {
        TreeListData = EmployeeTaskService.GenerateData();
    }

    protected override void OnAfterRender(bool firstRender) {
        if (firstRender) {
            PageIndex = MyTreeList.GetPageCount() - 1;
            StateHasChanged();
        }
    }
}

Blazor TreeList Page Count

For more information about paging in the TreeList component, refer to the following topic: Paging in Blazor TreeList.

See Also