且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PrimeFaces dataTable滚动条在所需位置

更新时间:2023-10-09 08:49:46

我使用以下帖子完成了上述操作

I did the above using the following post

primeface数据表滚动条位置

数据表滚动

我的代码

脚本

function saveScrollPos() {
var scrollPos = jQuery('#receptionFORM\\:receptionTV\\:scheduleDataTable .ui-datatable-scrollable-body').prop('scrollTop');
document.getElementById('receptionFORM:scrollPos').value = scrollPos;
}

function autoScroll() {
var scrollPos = document.getElementById('receptionFORM:scrollPos').value;
jQuery('#receptionFORM\\:receptionTV\\:scheduleDataTable .ui-datatable-scrollable-body').animate({scrollTop:scrollPos}, scrollPos); 
}

HiddenInput

HiddenInput

<h:inputHidden id="scrollPos" />

在数据表行的Ajax事件中选择

In Ajax event of datatable row select

onstart="saveScrollPos()"

保存记录时,在CommandButton中使用以下代码

The below code in CommandButton while saving record

oncomplete="autoScroll()"