Replace DataViewControlsComponent
In OneCX v6, Replace p-dataView and DataViewControlsComponent template with InteractiveDataViewComponent.
Code Changes
-
Remove
<ocx-data-view-controls>andDataViewControlsComponentfrom@onecx/portal-integration-angular -
Add
InteractiveDataViewComponentfrom@onecx/angular-accelerator. -
Replace the entire
<p-dataView>with<ocx-interactive-data-view> -
Remove
DataViewModulefromprimeng/dataviewif not used elsewhere -
Add
<ocx-interactive-data-view>and update input properties and output events as per tables below
Example
<p-dataView [value]="items" [layout]="'grid'" [paginator]="true" [rows]="20">
<ng-template pTemplate="header">
<ocx-data-view-controls
[supportedViews]="['grid']"
[initialViewMode]="'grid'"
[filterValue]="filterValue"
[enableFiltering]="true"
(filterChange)="onFilterChange($event, dataView)"
[enableSorting]="false"
></ocx-data-view-controls>
</ng-template>
<ng-template pTemplate="gridItem" let-item>
<div class="card">
<div>{{ item.name }}</div>
</div>
</ng-template>
</p-dataView>
<ocx-interactive-data-view
[data]="items"
[supportedViewLayouts]="['grid']"
[layout]="'grid'"
[columns]="columns"
[filters]="filters"
[filter]="filterValue"
[clientSideFiltering]="true"
[emptyResultsMessage]="'ACTIONS.SEARCH.NO_DATA' | translate"
(filtered)="onFilterChange($event)"
(sorted)="onSortChange($event)"
(dataViewLayoutChange)="onDataViewChange($event)"
>
<ng-template pTemplate="item" let-item>
<div class="card">
<div>{{ item.name }}</div>
</div>
</ng-template>
</ocx-interactive-data-view>
Properties Mapping
Input Properties (DataViewControlsComponent)
DataViewControlsComponent |
InteractiveDataViewComponent |
Notes |
|---|---|---|
supportedViews |
supportedViewLayouts |
Indicates available layouts. Example: |
initialViewMode |
layout |
Sets initial layout. Example: |
filterValue |
filter |
Filters to apply. Use the |
enableFiltering |
clientSideFiltering |
Enable client-side filtering. Example: |
enableSorting |
clientSideSorting |
Enable client-side sorting. Example: |
sortingOptions |
columns |
Configure sorting per column by setting |
defaultSortOption |
sortField |
Use the column id for the default sort field. Example: |
defaultSortDirection |
sortDirection |
Use the |
columnDefinitions |
columns |
Use |
columnTemplates |
pTemplate with selectors |
Use |
dropdownPlaceholderText |
- |
Deprecated. Use translations (i18n); there is no direct input in the new component. |
filterColumns |
filters |
Use |
translations |
- |
Use i18n / translation keys. |
Input Properties (p-dataView)
p-dataView |
InteractiveDataViewComponent |
Notes |
|---|---|---|
value |
data |
Defines the component’s data source. Example: |
paginator |
listGridPaginator, tablePaginator |
listGridPaginator and tablePaginator are enabled by default |
rows |
pageSize |
Number of items per page. Example: |
rowsPerPageOptions |
pageSizes |
Array of page size options. Example: |
alwaysShowPaginator |
- |
The paginator is shown listGridPaginator |
showCurrentPageReport |
- |
The paginator shows the current page report by default when enabled. |
currentPageReportTemplate |
- |
Use the |
filterBy |
- |
Use |
emptyMessage |
emptyResultsMessage |
Message displayed when no data is available. |
Output Events
DataViewControlsComponent |
InteractiveDataViewComponent |
Notes |
|---|---|---|
sortChange, sortDirectionChange |
sorted |
Emits |
filterChange |
filtered |
Emits Filter[] |
dataViewChange |
dataViewLayoutChange |
Emits |
columnsChange |
displayedColumnKeysChange |
Emits string[] which contains the ids of the displayed columns |
Additional Notes
Template Transformation
Details
p-dataView |
InteractiveDataViewComponent |
Notes |
|---|---|---|
|
|
Keep header template for custom content. Remove only |
|
|
Use |
<ng-template let-roles pTemplate="gridItem">
<section>
<article *ngFor="let role of roles; index as i">
<a (click)="onEditRole($event, role)" [id]="'ws_roles_grid_data_row_' + i"> ... </a>
</article>
</section>
</ng-template>
<ng-template pTemplate="item" let-item let-i="index">
<section>
<article class="col-...">
<a (click)="onEditRole($event, item)" [id]="'ws_roles_grid_data_row_' + i"> ... </a>
</article>
</section>
</ng-template>