Компоненты PrimeNG
TreeTable
Документация

Документация древовидных таблиц

PrimeNG/TreeTable (opens in a new tab)

Древовидная таблица используется для отображения иерархических данных в табличном формате.

С чего начать

Подключите модуль

import { TreeTableModule } from 'primeng/treetable';
import { TreeNode } from 'primeng/api';

Свойства

NameTypeDefaultDescription
valuearraynullAn array of objects to display.
columnsarraynullAn array of objects to represent dynamic columns.
stylestringnullInline style of the component.
styleClassstringnullStyle class of the component.
tableStyleanynullInline style of the table.
tableStyleClassstringnullStyle class of the table.
autoLayoutbooleanfalseWhether the cell widths scale according to their content or not.
lazybooleanfalseDefines if data is loaded and interacted with in lazy manner.
lazyLoadOnInitbooleantrueWhether to call lazy loading on initialization.
paginatorbooleanfalseWhen specified as true, enables the pagination.
rowsnumbernullNumber of rows to display per page.
firstnumber0Index of the first row to be displayed.
totalRecordsnumbernullNumber of total records, defaults to length of value when not defined.
pageLinksnumbernullNumber of page links to display in paginator.
rowsPerPageOptionsarraynullArray of integer/object values to display inside rows per page dropdown of paginator
alwaysShowPaginatorbooleantrueWhether to show it even there is only one page.
showFirstLastIconbooleantrueWhen enabled, icons are displayed on paginator to go first and last page.
paginatorPositionstringbottomPosition of the paginator, options are "top","bottom" or "both".
paginatorDropdownAppendToanynullTarget element to attach the paginator dropdown overlay, valid values are "body" or a local ng-template variable of another element (note: use binding with brackets for template variables, e.g. [appendTo]="mydiv" for a div element having #mydiv as variable name).
currentPageReportTemplatestring(currentPage of totalPages)Template of the current page report element. Available placeholders are currentPage , totalPages , rows , first , last and totalRecords
showCurrentPageReportbooleanfalseWhether to display current page report.
showJumpToPageDropdownbooleanfalseWhether to display a dropdown to navigate to any page.
showPageLinksbooleantrueWhether to show page links.
defaultSortOrdernumber1Sort order to use when an unsorted column gets sorted by user interaction.
sortModestringsingleDefines whether sorting works on single column or on multiple columns.
resetPageOnSortbooleantrueWhen true, resets paginator to first page after sorting.
customSortbooleanfalseWhether to use the default sorting or a custom one using sortFunction.
sortFieldstringnullName of the field to sort data by default.
sortOrdernumber1Order to sort when default sorting is enabled.
multiSortMetaarraynullAn array of SortMeta objects to sort the data by default in multiple sort mode.
sortFunctionfunctionnullAn event emitter to invoke on custom sorting, refer to sorting section for details.
filtersarraynullAn array of FilterMetadata objects to provide external filters.
filterDelaynumber300Delay in milliseconds before filtering the data.
globalFilterFieldsarraynullAn array of fields as string to use in global filtering.
filterModestringlenientMode for filtering valid values are "lenient" and "strict". Default is lenient.
filterLocalestringundefinedLocale to use in filtering. The default locale is the host environment's current locale.
selectionModestringnullSpecifies the selection mode, valid values are "single" and "multiple".
selectionanynullSelected row in single mode or an array of values in multiple mode.
contextMenuSelectionanynullSelected row with a context menu.
dataKeystringnullA property to uniquely identify a record in data.
metaKeySelectionbooleantrueDefines whether metaKey is should be considered for the selection. On touch enabled devices, metaKeySelection is turned off automatically.
compareSelectionBystringdeepEqualsAlgorithm to define if a row is selected, valid values are "equals" that compares by reference and "deepEquals" that compares all fields.
rowHoverbooleanfalseAdds hover effect to rows without the need for selectionMode.
loadingbooleanfalseDisplays a loader to indicate data load is in progress.
loadingIconstringpi pi-spinnerThe icon to show while indicating data load is in progress.
showLoaderbooleantrueWhether to show the loading mask when loading property is true.
scrollablebooleanfalseWhen specifies, enables horizontal and/or vertical scrolling.
scrollHeightstringnullHeight of the scroll viewport in fixed pixels or the "flex" keyword for a dynamic size.
virtualScrollbooleanfalseWhether the data should be loaded on demand during scroll.
virtualRowHeightnumber28Height of a row to use in calculations of virtual scrolling.
minBufferPxnumbernullMinimum amount of content buffer (in pixels) that the viewport must render.
maxBufferPxnumbernullConfigures how much buffer space to render back up to when it detects that more buffer is required.
frozenWidthstringnullWidth of the frozen columns container.
frozenColumnsarraynullAn array of objects to represent dynamic columns that are frozen.
resizableColumnsbooleanfalseWhen enabled, columns can be resized using drag and drop.
columnResizeModestringfitDefines whether the overall table width should change on column resize, valid values are "fit" and "expand".
reorderableColumnsbooleanfalseWhen enabled, columns can be reordered using drag and drop.
contextMenuContextMenunullLocal ng-template varilable of a ContextMenu.
rowTrackByFunctionnullFunction to optimize the dom operations by delegating to ngForTrackBy, default algoritm checks for object identity.

События

NameParametersDescription
onNodeExpandevent.originalEvent: Browser event<br>node: Expanded node.Callback to invoke when a node is expanded.
onNodeCollapseevent.originalEvent: Browser event<br>node: Collapsed node.Callback to invoke when a node is collapsed.
onPageevent.first: Index of first record in page<br>event.rows: Number of rows on the pageCallback to invoke when pagination occurs.
onSortevent.field: Field name of the sorted column<br>event.order: Sort order as 1 or -1<br>event.multisortmeta: Sort metadata in multi sort mode. See multiple sorting section for the structure of this object.Callback to invoke when a column gets sorted.
onFilterevent.filters: Filters object having a field as the property key and an object with value, matchMode as the property value.<br>event.filteredValue: Filtered data after running the filtering.Callback to invoke when data is filtered.
onLazyLoadevent.first = First row offset<br>event.rows = Number of rows per page<br>event.sortField = Field name to sort with<br>event.sortOrder = Sort order as number, 1 for asc and -1 for dec<br>event.multiSortMeta: An array of SortMeta objects used in multiple columns sorting. Each SortMeta has field and order properties.<br>event.filters: FilterMetadata object having field as key and filter value, filter matchMode as value<br>event.globalFilter: Value of the global filter if availableCallback to invoke when paging, sorting or filtering happens in lazy mode.
onColResizeevent.element: Resized column header<br>event.delta: Change of width in number of pixelsCallback to invoke when a column is resized.
onColReorderevent.dragIndex: Index of the dragged column<br>event.dropIndex: Index of the dropped column<br>event.columns: Columns array after reorder.Callback to invoke when a column is reordered.
onNodeSelectevent.originalEvent: Browser event<br>event.nıde: Selected nodeCallback to invoke when a node is selected.
onNodeUnselectevent.originalEvent: Browser event<br>event.data: Unselected nodeCallback to invoke when a node is unselected.
onContextMenuSelectevent.originalEvent: Browser event<br>event.node: Selected nodeCallback to invoke when a node is selected with right click.
onHeaderCheckboxToggleevent.originalEvent: Browser event<br>event.checked: State of the header checkboxCallback to invoke when state of header checkbox changes.
onEditInitevent.column: Column object of the cell<br>event.data: Node dataCallback to invoke when a cell switches to edit mode.
onEditCompleteevent.column: Column object of the cell<br>event.data: Node dataCallback to invoke when cell edit is completed.
onEditCancelevent.column: Column object of the cell<br>event.data: Node dataCallback to invoke when cell edit is cancelled with escape key.

Методы

NameParametersDescription
reset-Clears the sort and paginator state.

Стилизация

NameElement
p-treetableContainer element.
p-treetable-captionCaption element.
p-treetable-summarySection section.
p-sortable-columnSortable column header.
p-treetable-scrollable-headerContainer of header in a scrollable table.
p-treetable-scrollable-bodyContainer of body in a scrollable table.
p-treetable-scrollable-footerContainer of footer in a scrollable table.
p-treetable-loadingLoader mask.
p-treetable-loading-contentLoader content.
p-treetable-wrapperLoader content.
p-treetable-scrollable-wrapperLoader content.
p-treetable-resizer-helperVertical resize indicator bar.
p-treetable-reorder-indicator-topTop indicator of column reordering.
p-treetable-reorder-indicator-topBottom indicator of column reordering.