Primefaces Datatable frozenHeader和scrollableHeader组,标题高度未命中匹配

时间:2016-04-22 10:27:19

标签: primefaces datatable frozen-columns

我用主面5.2创建数据表 我使用FrozenHaeader和scrollableHeader。

我是从

中读到的
  

lost header datatable use frozen column primeface

问题

标题列高度在FrozenHaeader和scrollableHeader之间不同步 关注图片: Datatable frozen column picture

我的代码

<p:dataTable var="result"  value="#{reportBRBean.listZone2}" id="dataTb" selectionMode="single" selection="#{reportBRBean.selectedZone}" 
 frozenColumns="3"      scrollable="true" scrollWidth="800"

 rowIndexVar="rowIndex" rowStyleClass="#{(rowIndex mod 2) eq 0 ? 'even' : 'odd'}" rowKey="#{result.zoneCode}"  >

frozenHeader:

<p:columnGroup type="frozenHeader"  >
<p:row>
<p:column  rowspan="4" width="20" style="background-color: #00CCCC !important;"/>
<p:column  rowspan="4" headerText="#{msg['br1.zone.lb.zone']}" width="140" style="background-color: #00CCCC !important;"/>
<p:column rowspan="4" headerText="#{msg['br2.lb.amount.birth.certificate']}" width="110" style="background-color: #00CCCC !important;"/>
</p:row></p:columnGroup>

scrollableHeader:

<p:columnGroup type="scrollableHeader"  >
<p:row>
<p:column colspan="10"  headerText="#{msg['br2.lb.amount.inform.birth']}" width="900" style="background-color: #00CCCC !important;"/>
<p:column rowspan="4" headerText="#{msg['br2.lb.percent.inform.birth.all']}" width="100" style="background-color: #ffcc66 !important;"/>
<p:column colspan="10" headerText="#{msg['br2.lb.amount.noinform.birth']}" width="900" style="background-color: #00CCCC !important;"/>
<p:column rowspan="4" headerText="#{msg['br2.lb.percent.noinform.birth.all']}" width="100" style="background-color: #ffcc66 !important;"/>
</p:row>
<p:row>
<p:column colspan="4"  headerText="#{msg['br2.lb.amount.inform.within15']}" style="background-color: #ff99ff !important;"/>
<p:column rowspan="3"  headerText="#{msg['br2.lb.percent.inform.within15']}" style="background-color: #ffff99 !important;"/>
<p:column colspan="4"  headerText="#{msg['br2.lb.amount.inform.over15']}" style="background-color: #ff99ff !important;"/>
<p:column rowspan="4"  headerText="#{msg['br2.lb.percent.inform.over15']}" style="background-color: #ffff99 !important;"/>
<p:column colspan="4"  headerText="#{msg['br2.lb.amount.noinform.within15']}" style="background-color: #ff99ff !important;"/>
<p:column rowspan="3"  headerText="#{msg['br2.lb.percent.noinform.within15']}" style="background-color: #ffff99 !important;"/>
<p:column colspan="4"  headerText="#{msg['br2.lb.amount.noinform.over15']}" style="background-color: #ff99ff !important;"/>
<p:column rowspan="4"  headerText="#{msg['br2.lb.percent.noinform.over15']}" style="background-color: #ffff99 !important;"/>
</p:row>

谢谢

1 个答案:

答案 0 :(得分:0)

我使用javascript修复。

我在(oncomplete)数据表生成后调用javascript。

<script type="text/javascript">
         /*<![CDATA[*/

        function synchronizeRowsHeight() {


            var $rows = $(document.getElementById('doctorForm:resultDoctorService_frozenThead')).find('tr');
                        $rows.each(function(index) {
                            var $row = $(this);
                            $row.innerHeight($(document.getElementById('doctorForm:resultDoctorService_scrollableThead')).outerHeight());
                        });
                    }
                    // ]]>
</script>

<强> doctorForm:resultDoctorService_frozenThead

doctorForm ”表格ID

resultDoctorService ”数据表ID

frozenThead ”列组类型