I need to scroll datatable after adding a record to list. I have a datatable:
<p:scrollPanel id="tablewindowscroll" mode="native">
<p:dataTable scrollable="true" emptyMessage="" id="tablewindowwindow" style="width: 100%; height: 100%" var="msg" value="#{dtBasicView.messages}" rowStyleClass="#{msg.direction eq 0 ? 'stylequery' : 'styleresponse'}" styleClass="borderless">
</p:dataTable>
</p:scrollPanel>
<p:poll update=":j_id0:tablewindow" interval="2"/>
On button click im adding a record to this list (using classic List.add method in backing bean). How to force datatable to scroll to last element from backing bean after list update?
I tried:
function scrollToBottom() {
$('.ui-datatable-scrollable-body').scrollTop(100000)
}
But its not working by calling:
RequestContext.getCurrentInstance().execute("scrollToBottom();");
And to use:
<p:ajax update="myDataTable" oncomplete="scrollToBottom()"/>
I need an event relited to List.add from backing bean, but as im aware of such event does not exist
How to scroll a datatable to bottom from backing bean after list modification?
Best regards and thanks!
$('.ui-datatable-scrollable-body').scrollTop(100000)in the online primefaces showcase primefaces.org/showcase/ui/data/datatable/scroll.xhtml and it works fine. you also have a scroll panel. Maybe that messes things up - Kukeltje