h:JSF2 中的 dataTable 交替行
我试图在 JSF2 h:dataTable 中交替行(没有 richfaces 等),但我得到了意想不到的结果。该表已构建,但显示了一个白色网格(但我没有指定任何边框),并且每行下方没有底线。
CSS:
.order-table{
border-collapse:collapse;
}
.order-table-header{
text-align:center;
background:none repeat scroll 0 0 #E5E5E5;
border-bottom:1px solid #95bce2;
padding:16px;
}
.order-table-odd-row{
text-align:center;
background:none repeat scroll 0 0 #FFFFFFF;
border-top:1px solid #000000;
}
.order-table-even-row{
text-align:center;
background:none repeat scroll 0 0 #ecf6fc;
border-top:1px solid #BBBBBB;
}
table.order-table tr.over {
background-color: #bcd4ec;
}
表格:
<h:dataTable id="personsTable" value="#{personController.allPersons}" var="bean"
styleClass="order-table" headerClass="order-table-header"
rowClasses="order-table-odd-row,order-table-even-row">
<h:column>
<f:facet name="header">
<h:outputText value="First Name" />
</f:facet>
<h:outputText value="#{bean.firstName}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Last Name" />
</f:facet>
<h:outputText value="#{bean.lastName}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Phone" />
</f:facet>
<h:outputText value="#{bean.phone}"/>
</h:column>
</h:dataTable>
和一个小的 JQuery 脚本:
<script type="text/javascript">
$(document).ready(function(){
$(".order-table tr").mouseover(function(){
$(this).addClass("over");
});
$(".order-table tr").mouseout(function(){
$(this).removeClass("over");
});
});
</script>
结果是(注意白色网格,我不知道来自哪里。而且也没有应该来自 CSS 的下划线):
I'm trying to make alternating rows in JSF2 h:dataTable (no richfaces or such) but i get an unexpected result. the table is built but it has a white grid shown (but i didn't specifiy any border) and there's no buttom line under each row.
The CSS:
.order-table{
border-collapse:collapse;
}
.order-table-header{
text-align:center;
background:none repeat scroll 0 0 #E5E5E5;
border-bottom:1px solid #95bce2;
padding:16px;
}
.order-table-odd-row{
text-align:center;
background:none repeat scroll 0 0 #FFFFFFF;
border-top:1px solid #000000;
}
.order-table-even-row{
text-align:center;
background:none repeat scroll 0 0 #ecf6fc;
border-top:1px solid #BBBBBB;
}
table.order-table tr.over {
background-color: #bcd4ec;
}
The table:
<h:dataTable id="personsTable" value="#{personController.allPersons}" var="bean"
styleClass="order-table" headerClass="order-table-header"
rowClasses="order-table-odd-row,order-table-even-row">
<h:column>
<f:facet name="header">
<h:outputText value="First Name" />
</f:facet>
<h:outputText value="#{bean.firstName}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Last Name" />
</f:facet>
<h:outputText value="#{bean.lastName}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Phone" />
</f:facet>
<h:outputText value="#{bean.phone}"/>
</h:column>
</h:dataTable>
and a small JQuery script:
<script type="text/javascript">
$(document).ready(function(){
$(".order-table tr").mouseover(function(){
$(this).addClass("over");
});
$(".order-table tr").mouseout(function(){
$(this).removeClass("over");
});
});
</script>
The result is (notice the white grid that came from i don't know where. And also no underline which should come from the CSS):
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后我找到了难以捉摸的答案:
我缺少的是:表声明中的规则=“无”。
这个缺失的声明弄乱了我的 CSS 并部分忽略了它。
现在 CSS 可以正常工作了。
Finally i found the elusive answer:
What i was missing is: rules="none" in the table declaration.
This missing declaration managed to mess up my CSS and to partially ignore it.
Now the CSS is working fully.