lara-light-indigo

DataScroller

DataScroller displays data with on demand loading using scroll.

Demo is at the bottom of this page.
Import via Module

import { DataScroller } from 'primereact/datascroller';
 
Import via CDN

<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/datascroller/datascroller.min.js"></script>
 
Getting Started

DataScroller requires a collection of items as its value, number of rows to load and a template content to display. Here is a sample DataScroller that displays a list of cars where each load event adds 10 more rows if available.


<DataScroller value={products} itemTemplate={itemTemplate} rows={10}></DataScroller>
 

const itemTemplate = (item) => {
    // custom item content
}
 
Inline

By default DataScroller listens to the scroll event of window, the alternative is the inline mode where container of the DataScroller element itself is used as the event target. Set inline option to true to enable this mode.


<DataScroller value={products} itemTemplate={itemTemplate} rows={10} inline></DataScroller>
 
Lazy Loading

Lazy mode is handy to deal with large datasets, instead of loading the entire data, small chunks of data is loaded by invoking onLazyLoad callback everytime paging happens. To implement lazy loading, enable lazy property and provide a method callback using onLazyLoad that actually loads the data from a remote datasource. onLazyLoad gets an event object that contains information about what to load.


<DataScroller value={products} itemTemplate={itemTemplate} rows={10} lazy onLazyLoad={loadData}></DataScroller>
 

const loadData = (event) => {
    //event.first = First row offset
    //event.rows = Number of rows per page
    //add more records to the cars array
}
 
Properties
NameTypeDefaultDescription
idstringnullUnique identifier of the element.
valuearraynullAn array of objects to display.
rowsnumbernullNumber of rows to fetch in a load event.
inlinebooleanfalseDefines if the event target to listen the scroll event is the element itself.
scrollHeightanynullMax height of the content area in inline mode.
loaderbooleannullDetermines whether data is loaded by a target element.
buffernumber0.9Number of buffer size.
stylestringnullInline style of the component.
classNamestringnullStyle class of the component.
itemTemplatefunctionnullFunction that gets an item in the value and returns the content for it.
headeranynullLabel of header.
footeranynullLabel of footer.
emptyMessageanyNo records foundText to display when there is no data.
Events
NameParametersDescription
onLazyLoadevent.first = First row offset
event.rows = Number of rows per page
Callback to invoke in lazy mode to load new data.
Styling

Following is the list of structural style classes

NameElement
p-datascrollerContainer element.
p-datascroller-headerHeader section.
p-datascroller-footerFooter section.
p-datascroller-contentWrapper of item container.
p-datascroller-listItem container element.
Accessibility

This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.

List of Products
  • No results found

Component Scale

Input Style

Ripple Effect

Free Themes

Built-in component themes created by the PrimeReact Theme Designer.

Bootstrap
Blue
Purple
Blue
Purple
Material Design
Indigo
Deep Purple
Indigo
Deep Purple
Material Design Compact
Indigo
Deep Purple
Indigo
Deep Purple
Tailwind
Tailwind Light
Fluent UI
Blue
PrimeOne Design - 2022 NEW
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
PrimeOne Design - 2021
Saga Blue
Saga Green
Saga Orange
Saga Purple
Vela Blue
Vela Green
Vela Orange
Vela Purple
Arya Blue
Arya Green
Arya Orange
Arya Purple
Premium Themes

Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.

Soho Light
Soho Dark
Viva Light
Viva Dark
Mira
Nano

Legacy Free Themes

Nova
Nova Alt
Nova Accent
Luna Blue
Luna Green
Luna Amber
Luna Pink
Rhea

Premium Create-React-App Templates

Beautifully crafted premium create-react-app application templates by the PrimeTek design team.

Sakai
Atlantis
Freya
Ultima
Diamond
Sapphire
Serenity
Babylon
Avalon
Apollo
Roma