我在我的 JSF 数据表中添加了一个自定义滚动条,它看起来像这样:
我的代码是这样的:
<div class="verticalScrollbar" style="max-height:330px;">
<h:dataTable var="entity" value="#{entityBean.entities}"
styleClass="datatable"
headerClass="datatable-header"
rowClasses="datatable-odd-row,datatable-even-row">
<h:column>
<f:facet name="header">
<h:outputText value="Field 1" />
</f:facet>
<h:outputText value="#{entity.field1}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Field 2" />
</f:facet>
<h:outputText value="#{entity.field2}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Field 3" />
</f:facet>
<h:outputText value="#{entity.field3}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Field 4" />
</f:facet>
<h:outputText value="#{entity.field4}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Field 5" />
</f:facet>
<h:outputText value="#{entity.field5}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Field 6" />
</f:facet>
<h:outputText value="#{entity.field6}" />
</h:column>
</h:dataTable>
</div>
<script>
(function($){
$(window).load(function(){
$(".verticalScrollbar").mCustomScrollbar({
scrollButtons:{ enable:false },
horizontalScroll:false,
advanced:{ updateOnBrowserResize:true, updateOnContentResize:true }
});
});
})(jQuery);
</script>
verticalScrollbar div 包含整个数据表,包括标题,所以当我向下滚动表格时,我看不到标题,如下所示:
如何仅将滚动条应用于不包括标题的表格正文,以便标题保持静止,而只有正文向下滚动?