Sticky Header Component
Overview
The sticky header component is responsible for rendering additional grid header and grid toolbar.
Sticky header is displayed when the persistent header gets hidden during vertical scrolling. The persistent header reactivates when you scroll back up:
The following image is an illustration of a grid with a sticky header:
Enable sticky header for a grid
To enable the sticky header functionality for a certain grid, declare it as a child element in the grid configuration file using the following notation:
Where the following should be specified:
toolbarProvider
: full name of the toolbar component on this page.listingProvider
: full name of the listing (grid) component on this page; the one for which the sticky header is enabled.
Example
Enabling a sticky header for the CMS pages grid, configured in <Magento_Cms_module_dir>/view/adminhtml/ui_component/cms_page_listing.xml
:
Sticky header configuration
Any component of a sticky header can use a particular, not default template. This template is set in the stickyTmpl
option. If the sticky template is not set, the default component’s template is used for displaying in a sticky header.
Example
The toolbar component should use the ui/grid/sticky/toolbar
template for the sticky header.
<Magento_Cms_module_dir>/view/adminhtml/ui_component/cms_page_listing.xml
:
Component elements
The sticky header component consists of the following elements:
- Constructor:
<Magento_Ui_module_dir>/view/base/web/js/grid/sticky/sticky.js
- Main template:
<Magento_Ui_module_dir>/view/base/web/templates/grid/sticky/sticky.html
- Elements’ templates:
Dependencies
The sticky header component depends on the following components:
- Listing
- Toolbar
It also works both with and without the following components, preserving their functionality:
- Listing child components:
- Dnd
- Resize
- Bulk Edit
- Inline Edit
- Toolbar child components: