this.content = el}>
+
this.content = el}>
{items}
- );
+ )
if (this.props.contentTemplate) {
- const { loading, first, last } = this.state;
-
const defaultOptions = {
- className: 'p-virtualscroller-content',
- ref: (el) => this.content = el,
+ className,
+ contentRef: (el) => this.content = el,
+ spacerRef: (el) => this.spacer = el,
+ stickyRef: (el) => this.sticky = el,
+ items: loadedItems,
+ getItemOptions: (index) => this.getOptions(index),
children: items,
element: content,
props: this.props,
- loading,
- first,
- last
- };
+ loading: this.state.loading,
+ getLoaderOptions: (index, ext) => this.loaderOptions(index, ext),
+ loadingTemplate: this.props.loadingTemplate,
+ itemSize: this.props.itemSize,
+ rows: this.getRows(),
+ columns: this.getColumns(),
+ vertical: this.isVertical(),
+ horizontal: this.isHorizontal(),
+ both: this.isBoth()
+ }
return ObjectUtils.getJSXElement(this.props.contentTemplate, defaultOptions);
}
@@ -554,22 +639,35 @@ export class VirtualScroller extends Component {
}
render() {
- const isBoth = this.isBoth();
- const isHorizontal = this.isHorizontal();
- const className = classNames('p-virtualscroller', {
- 'p-both-scroll': isBoth,
- 'p-horizontal-scroll': isHorizontal
- }, this.props.className);
+ if (this.props.disabled) {
+ const content = ObjectUtils.getJSXElement(this.props.contentTemplate, { items: this.props.items, rows: this.props.items, columns: this.props.columns });
- const loader = this.renderLoader();
- const content = this.renderContent();
+ return (
+
+ {this.props.children}
+ {content}
+
+ )
+ }
+ else {
+ const isBoth = this.isBoth();
+ const isHorizontal = this.isHorizontal();
+ const className = classNames('p-virtualscroller', {
+ 'p-both-scroll': isBoth,
+ 'p-horizontal-scroll': isHorizontal
+ }, this.props.className);
- return (
-
this.element = el} className={className} tabIndex={0} style={this.props.style} onScroll={this.onScroll}>
- {content}
-
this.spacer = el} className="p-virtualscroller-spacer">
- {loader}
-
- );
+ const loader = this.renderLoader();
+ const content = this.renderContent();
+ const spacer = this.renderSpacer();
+
+ return (
+
this.el = el} className={className} tabIndex={0} style={this.props.style} onScroll={this.onScroll}>
+ {content}
+ {spacer}
+ {loader}
+
+ )
+ }
}
}
diff --git a/src/showcase/virtualscroller/VirtualScrollerDoc.js b/src/showcase/virtualscroller/VirtualScrollerDoc.js
index deb9696bf4..1db8942d40 100644
--- a/src/showcase/virtualscroller/VirtualScrollerDoc.js
+++ b/src/showcase/virtualscroller/VirtualScrollerDoc.js
@@ -935,16 +935,24 @@ const onLazyLoad = (event) => {
{`
const contentTemplate = (options) => {
// options.className: Class name of wrapper element.
- // options.ref: Ref of wrapper element.
+ // options.contentRef: Ref of wrapper element.
+ // options.spacerRef: Ref of spacer element.
+ // options.stickyRef: Ref of sticky element in content.
+ // options.items: Loaded data.
+ // options.getItemOptions(index): Information of any item.
// options.children: Items of wrapper element.
// options.element: Default wrapper element.
// options.props: Props of component.
// options.loading: Whether the data is loaded.
- // options.first: First index.
- // options.last: Last index
+ // options.getLoaderOptions(index): Information of any item during the loading.
+ // options.loadingTemplate: Template of loading item.
+ // options.itemSize: The height/width of item according to orientation.
+ // options.vertical: Whether the orientation is vertical.
+ // options.horizontal: Whether the orientation is horizontal.
+ // options.both: Whether the orientation is both.
return (
-
+
);
@@ -1035,6 +1043,30 @@ const itemTemplate = (item, options) => {
false |
Defines if data is loaded and interacted with in lazy manner. |
+
+ disabled |
+ boolean |
+ false |
+ If disabled, the VirtualScroller feature is eliminated and the content is displayed directly. |
+
+
+ loaderDisabled |
+ boolean |
+ false |
+ Used to implement a custom loader instead of using the loader feature in the VirtualScroller. |
+
+
+ loading |
+ boolean |
+ false |
+ Whether the data is loaded. |
+
+
+ showSpacer |
+ boolean |
+ true |
+ Used to implement a custom spacer instead of using the spacer feature in the VirtualScroller. |
+
showLoader |
boolean |