如何删除<p:datatable> </p:datatable>中的水平滚动条

时间:2014-05-27 12:15:18

标签: css jsf primefaces datatable scrollbar

我试图隐藏水平滚动条。
我尝试了很多解决方案,但它似乎没有用。 我试过的解决方案是here
这是我在XHTML中使用的代码

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">

    <h:form id="commentsform">
        <p:outputPanel id="commenttable">
            <p:dataTable id="commentsdt" var="row" stickyHeader="true"
                value="#{bean.displayCommentsDetailsList}"
                selection="#{bean.selectedComments}"
                rowKey="#{row.commentDate}" rows="20" paginator="true"
                paginatorPosition="bottom" rowIndexVar="index"
                paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                scrollable="true" scrollHeight="150" style="width:100%;overflow-x:hidden;overflow-y:auto;"
                rowStyleClass="#{row.changeFieldFlg==true ? 'highlight' : null}">

                <f:facet name="header">
                    <h:panelGrid columnClasses="alignRight">
                        <p:commandButton
                            disabled="#{bean.editCmdActionflg == false}"
                            actionListener="#{bean.addComments}"
                            update="commentsdt :SystemDetailsinfoForm:line :growl :error"
                            partialSubmit="true" title="Add Row.." icon="ui-icon-plusthick"
                            styleClass="iconButton" />
                    </h:panelGrid>
                </f:facet>

                <p:column width="160" headerText="Date" style="width:150px">
                    <h:outputText value="#{row.commentDate}" style="width:150px" />
                </p:column>
                <p:column width="160" headerText="Author" style="width:150px">
                    <h:outputText value="#{row.author}" style="width:150px" />
                </p:column>
                <p:column width="100" headerText="Deliverable" style="width:90px"
                    rendered="#{bean.selectedChoice == '2'}">
                    <h:outputText value="#{row.delivName}"
                        rendered="#{bean.selectedChoice == '2'}"
                        style="width:90px" />
                </p:column>
                <p:column headerText="Comments">
                    <div align="left">
                        <h:outputText value="#{row.comments}"
                            rendered="#{row.editableflg==false}"></h:outputText>
                        <p:inputTextarea value="#{row.comments}"
                            style="width:98%;float:left" rendered="#{row.editableflg==true}">
                        </p:inputTextarea>
                    </div>
                </p:column>

            </p:dataTable>
        </p:outputPanel>
    </h:form>
</ui:composition><br/>

我尝试使用overflow-y:scroll; overflow-x:hidden;隐藏水平滚动条,但似乎没有一个应用于数据表。
请让我知道您解决此问题的建议

3 个答案:

答案 0 :(得分:6)

我刚刚为<p:dataTable>制作了一个自定义样式,并在其中调用了该样式。

我写的风格是

.mystyle.ui-datatable .ui-datatable-scrollable-body{
    overflow-y: scroll !important;
    overflow-x: hidden !important;
}


我在下面给出的<p:dataTable>中调用了样式 styleClass =&#34; mystyle&#34;

<p:dataTable id="commentsdt" var="row" stickyHeader="true"
                value="#{systemDetailsBean.displayCommentsDetailsList}"
                selection="#{systemDetailsBean.selectedComments}" rowKey="#{row.commentDate}"
                rows="20" paginator="true" paginatorPosition="bottom"
                rowIndexVar="index"
                paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                scrollHeight="150" scrollable="true" style="width:100%;"  styleClass="mystyle"
                rowStyleClass="#{row.changeFieldFlg==true ? 'highlight' : null}">

答案 1 :(得分:0)

就我而言,我有一个垂直滚动条,因为单元格中使用的一种样式定义了非零padding
滚动条重新定义为零padding的样式消失了。

答案 2 :(得分:0)

你可以添加20像素的高度,在我的情况下我添加了宽度,因为我在宽度上需要它。 所以我的div容器:

  .container {
height: 100%;
width: calc(100% + 20px);}

我使用了这个技巧,因为我只想隐藏垂直滚动条,不幸的是,我不知道如何只隐藏primeng数据表中的垂直滚动条。我希望它对你有帮助