PrimeFaces dataTable scrollbar at desired position

前端 未结 1 1618
孤街浪徒
孤街浪徒 2021-01-01 03:03

I have a scrollable dataTable with 100+ records when I add a new record (outside the default viewable area)and update the datatable the dataTable gets loaded from record 0,

相关标签:
1条回答
  • 2021-01-01 03:36

    I did the above using the following post

    primeface datatable scrollbar position

    datatable scroll

    my code

    script

    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

    <h:inputHidden id="scrollPos" />
    

    In Ajax event of datatable row select

    onstart="saveScrollPos()"
    

    The below code in CommandButton while saving record

    oncomplete="autoScroll()"
    
    0 讨论(0)
提交回复
热议问题