Module: alfresco/lists/AlfSortablePaginatedList

alfresco/lists/AlfSortablePaginatedList

This extends the AlfHashList to provide support for common pagination and sorting behaviour. It does not render any interface for controlling the current page or sort preferences - the Paginator widget can be used for changing page and the number of items shown per page. Sorting can be controlled through the SortFieldSelect and SortOrderToggle widgets.

It is important to understand that this widget does not perform any client-side sorting or pagination, it simply controls the payloads published to services - successful pagination and sorting are determined by the ability of the service and the REST API ultimately called to support it.

It is possible to specify the pageSizePreferenceName to be used by this widget (or its descendants) when the PreferenceService is being used to set the intial page size. Alternatively it can be specified by the currentPageSize. Similarly the initial page number can be configured with the currentPage attribute. Page and page size data can also be derived from browser URL hash parameters when useHash is configured to be true.

Page navigation can also be performed with infinite scrolling when useInfiniteScroll is configured to be true and either the [InfiniteScrollService]{@link module:alfresco/services/InfiniteScrollService} is included in the page or the list is placed in an InfiniteScrollArea.

The initial field to sort on can be configured with the sortField and the initial sort direction can configured by setting sortAscending to true or false as appropriate. The sort field and direction can be changed by widgets (such as menus or buttons) publishing on the sortRequestTopic topic.

Author:
  • Dave Draper
License:
Source:

Example

AlfSortablePaginatedList with associated sort and pagination widgets

{
  name: "alfresco/lists/Paginator",
  config: {
    pageSizes: [5,10,20],
    widgetsAfter: [
      {
        name: "alfresco/lists/SortFieldSelect",
        config: {
          sortFieldOptions: [
            { label: "Display Name", value: "fullName" },
            { label: "User Name", value: "userName" }
          ]
        }
      },
      {
        name: "alfresco/lists/SortOrderToggle"
      }
    ]
  }
},
{
  name: "alfresco/lists/AlfSortablePaginatedList",
  config: {
    loadDataPublishTopic: "ALF_GET_USERS",
    currentPageSize: 10,
    sortField: "fullName",
    widgets: [
      {
        name: "alfresco/lists/views/HtmlListView"
      }
    ]
  }
}

Members

currentPage :number

The current page number being shown.
Type:
  • number
Default Value:
  • 1
Source:

currentPageSize :number

The size (or number of items) to be shown on each page.
Type:
  • number
Default Value:
  • 25
Source:

i18nRequirements :object[]

An array of the i18n files to use with this widget. This re-uses the Paginator i18n properties.
Type:
  • object[]
Default Value:
  • [{i18nFile: "./i18n/Paginator.properties"}]
Source:

pageSizePreferenceName :string

The name of the property to access in order to retrieve the page-size preference for this widget
Type:
  • string
Default Value:
  • "org.alfresco.share.documentList.documentsPerPage"
Source:

sortAscending :boolean

The inital sort order.
Type:
  • boolean
Default Value:
  • true
Source:

sortField :string

The initial field to sort results on. For historical reasons the default is the "cm:name" property (because the DocumentLibrary was the first implementation of this capability.
Type:
  • string
Default Value:
  • "cm:name"
Source:

sortFieldLabel :string

The initial label of the sort field. It is not necessary to set this if no other widgets require it. However, it will be updated on external sort requests if a "label" attribute is provided. The reason for setting it is so that other widgets (such as an AlfMenuBarSelect) used to control the sort field can be updated with the appropriate label.
Type:
  • string
Since:
  • 1.0.73
Source:

usePagination :boolean

Indicates whether pagination should be used when requesting documents (e.g. include the page number and the number of results per page)
Type:
  • boolean
Default Value:
  • true
Source:

Methods

_updateCoreHashVars(hashParameters)

Checks the hash for updates relating to pagination and sorting.
Parameters:
Name Type Description
hashParameters object An object containing the current hash parameters
Source:

onFiltersUpdated()

Extends the inherited function to ensure that when a new filter is set the page is reset to the first page.
Source:

onItemsPerPageChange(payload)

Handles requests to change the number of items shown for each page of data in the list. When the page size is increased or decreased the current page will be adjusted to attempt to keep the items that the user was looking at in the requested page. This is simple when increasing the page size, but harder when decreasing the page size. When decreasing the page size the page requested will represent the beginning of the larger page size of data, e.g. when going from 50 - 25 items per page, if the user was on page 2 (51-100) then page 3 (51-75) would be requested.
Parameters:
Name Type Description
payload object The details of the new page size
Source:

onPageChange(payload)

Parameters:
Name Type Description
payload object The details of the new page number
Source:

onReloadData()

Extends the inherited function to reset the current page size on a reload request when infinite scroll is enabled.
Source:

onScrollNearBottom(payload)

Overrides the inherited function to request more data when the user scrolls to the bottom of the browser page.
Parameters:
Name Type Description
payload
Source:

onSortFieldSelection(payload)

Parameters:
Name Type Description
payload object The details of the request
Source:

onSortRequest(payload)

Parameters:
Name Type Description
payload object The details of the request
Source:

postMixInProperties()

Extends the inherited function to request the users documents per page preference.
Source:

setPageSize(value)

Sets the number of documents per page
Parameters:
Name Type Description
value number The number of documents per page.
Source:

setupSubscriptions()

Extends the inherited function to add in additional subscriptions for the common sorting and pagination topics.
Source:

showView()

Extends the inherited function to set the sort data for any HeaderCell widgets that might be included in the view.
Since:
  • 1.0.59
Source:
Fires:
  • module:alfresco/lists//AlfSortablePaginatedList#event:sortRequestTopic

updateLoadDataPayload(payload)

Extends the inherited function to add the additional pagination and sorting data to the supplied payload object.
Parameters:
Name Type Description
payload object The payload object to update
Source:

<inner> resetPaginationData()

Reset the pagination data. This method is useful, e.g., when navigation between different list views.
Source: