丰富:数据表和可扩展列与 Internet Explorer
我使用 rich:datatable 和 rich:column 创建了一个用于可扩展列/行的简单解决方案,类似于: 制作可扩展/可折叠的最佳方法subTable with rich:dataTable
Facelets 代码(简化)如下:
<rich:dataTable id="detailtable"
value="#{bean.model}"
var="row"
columns="2">
<rich:column id="detail-check">
<f:facet name="header">
<h:selectBooleanCheckbox value="#{bean.expandAll}">
<a4j:support event="onchange" action="#{bean.expandAllAction}"
reRender="detailtable" />
</h:selectBooleanCheckbox>
</f:facet>
<h:selectBooleanCheckbox value="#{row.expanded}">
<a4j:support event="onchange" reRender="detailtable" />
</h:selectBooleanCheckbox>
</rich:column>
<!-- actual data column -->
<rich:column id="detail-column"
rendered="#{row.expanded}"
breakBefore="true"
colspan="2">
<!-- detail column content -->
</rich:column>
</rich:dataTable>
当您单击详细信息框时,这会提供一个带有扩展列的表,详细信息列将呈现在实际行下方。支持 bean 上的 ExpandAllAction 只是迭代行并将其扩展属性设置为与支持 bean 中相同,从而扩展/取消扩展所有行。
然而,尽管它适用于 FF 和 Chrome,但它在 Internet Explorer(IE7 或 IE8)上无法正常工作。如果用户单击复选框,则不会呈现任何内容,直到他单击页面上的任何其他位置。支持 bean 和对象正在更新,但在单击其他某个元素之前不会重新渲染。
这到底是 IE 的问题还是 Richfaces 的 bug?我在 IE 和 tbody 中发现了一些类似的问题,但它应该已经修复了。我可以提交错误报告,但在此之前,有什么简单的解决方法吗?
Richfaces 版本是 3.3.1,它在 Jboss 4.2.1GA 和捆绑的 Sun RI 上运行。
I created a simple solution for expandable columns/rows with rich:datatable and rich:column, which is similar to: Best way to make an expandable/collapsible subTable with rich:dataTable
The facelets code is (simplified) as follows:
<rich:dataTable id="detailtable"
value="#{bean.model}"
var="row"
columns="2">
<rich:column id="detail-check">
<f:facet name="header">
<h:selectBooleanCheckbox value="#{bean.expandAll}">
<a4j:support event="onchange" action="#{bean.expandAllAction}"
reRender="detailtable" />
</h:selectBooleanCheckbox>
</f:facet>
<h:selectBooleanCheckbox value="#{row.expanded}">
<a4j:support event="onchange" reRender="detailtable" />
</h:selectBooleanCheckbox>
</rich:column>
<!-- actual data column -->
<rich:column id="detail-column"
rendered="#{row.expanded}"
breakBefore="true"
colspan="2">
<!-- detail column content -->
</rich:column>
</rich:dataTable>
This provides a table with expanded column when you click a detail box, the details-column is rendered below the actual row. expandAllAction on backing bean just iterates over rows and sets their expanded attribute to the same as in backing bean, thus expanding/unexpanding all rows.
However this does not work correctly with Internet Explorer (IE7 or IE8), although it works with FF and Chrome. If user clicks on checkbox, nothing is rendered until he clicks on any other place on page. Backing bean and objects are being updated, but no re-rendering until some other element is clicked.
Is this something wicked again with IEs or just a bug with Richfaces? I found some similar issue with IE and tbody, but it should have been fixed. I can file a bug report but until that, is there any simple workaround?
Richfaces version is 3.3.1 and it's run on Jboss 4.2.1GA and bundled Sun RI.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用其他事件,例如
onclick
来自 selectBooleanCheckBox 的 tldoc:
onchange
是“当该元素失去焦点并且其值在获得焦点后已被修改时执行的 JavaScript 代码”。onclick
是“当该元素失去焦点时执行的 JavaScript 代码”。在该元素上单击指针按钮。”昨天有一个类似问题。 BalusC 的一条评论可能会证实我的假设“在单选按钮/复选框的情况下,更改事件在某些浏览器中仅在单击 2 次时才会触发”
Try use another event like
onclick
From tldoc of selectBooleanCheckBox:
onchange
is "Javascript code executed when this element loses focus and its value has been modified since gaining focus." andonclick
is "Javascript code executed when a pointer button is clicked over this element."Yesterday was a similar question. One comment of BalusC might confirm my assumption "in case of radios/checkboxes the change event is in certain browsers only fired if you click 2 times"