PrimeFaces数据表滚动条位置 [英] PrimeFaces datatable scrollbar position
本文介绍了PrimeFaces数据表滚动条位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何设置素数数据表从最后到第一个的滚动条位置?
How to set a scrollbar position of primefaces datatable from last to first?
实际上,我想从下至上查看信息.下面是我的代码:
Actually, I want see the information from bottom to top. Below is my code:
<p:dataTable var="c" value="#{MessagingUserBean.inboxDetails1}" scrollable="true" scrollHeight="517" liveScroll="true" emptyMessage="No Message Found" scrollRows="8" scrollWidth="815" >
推荐答案
那么您可以尝试不使用liveScroll,因为这样您就不知道dataList的结尾.试试这个,也许这适合您的需求.这将向下滚动到dataTable的底部,并有一个延迟.
Well you can try to not use a liveScroll because you then don't know the end of dataList. Try this and maybe this suit your needs. This will scrolldown to the bottom of your dataTable with a delay.
<h:form prependId="false">
<p:dataTable id="dataTable" var="c" value="#{MessagingUserBean.inboxDetails1}" scrollHeight="517" liveScroll="true" emptyMessage="No Message Found" scrollWidth="815" >
//Your dataTable stuff
</p:dataTable>
</h:form>
<script>
//Get the scrollheight
var s = jQuery('#dataTable .ui-datatable-scrollable-body').prop('scrollHeight');
//Get total size of datatable
var o = jQuery('#dataTable .ui-datatable-scrollable-body').prop('offsetHeight');
//calculate how many times it can scrolldown to set your timer
var t = Math.ceil(s/o);
//Excute scrolldown animation (max scrolldown is scrollHeight - offsetHeight)
$('#dataTable .ui-datatable-scrollable-body').animate({scrollTop:s-0}, t*1000);
</script>
这篇关于PrimeFaces数据表滚动条位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文