scrollTo
scrollToIndex
scrollInView
in the Virtualscroller Module
my datatable (render) call looks as follows:
Code: Select all
return (
<div>
<div className="card" ref={domRef}>
<DataTable
// ref={(el) => tableRef = el}
ref={tableRef}
value={tableData}
onSort={sortMe}
onReset={resetMe}
scrollable
scrollHeight="400px"
virtualScrollerOptions={{
lazy: true,
onLazyLoad: loadDataLazy,
itemSize: 46,
delay: 100,
showLoader: true,
loading: lazyLoading,
loadingTemplate,
}}
>
Code: Select all
let dom_scroll = domRef.current.querySelector(".p-virtualscroller");
dom_scroll.scrollToIndex(10);
If I try:
Code: Select all
let dom_scroll = domRef.current.querySelector(".p-virtualscroller");
dom_scroll.scrollTo(0,0);
In the code (virtualscroller.esm.js Line 6993) it looks like, the scrollToIndex function exists:
Code: Select all
React.useImperativeHandle(ref, function () {
return {
scrollTo: scrollTo,
scrollToIndex: scrollToIndex,
scrollInView: scrollInView,
getRenderedRange: getRenderedRange
};
});
Is there a way, to position the (virtual) table to a specific position (index, oder selected element) ?
(
I googled for this over one week (primereact datatable scroll to index , move to index, virtualscroller position, get virtualscroller ref and so on), but didnt find any feasible solution.
.