目前我正在开发一个项目(JSF 2.0,RichFaces 3.3.3),其中我必须获得一个启用多列排序的 2 列 DataTable(我已经通过 sortMode="Multi"
sortMode="Multi" 属性),但是,与单列排序不同,在多列的情况下,我不可能释放正在执行排序的列(这是通过单击其他列标题在单列情况下完成的)。
排序顺序在会话期间被锁定:即使在选项卡之间切换时,我的 Web 应用程序也会维护当前的列排序设置。我需要在会话中恢复此配置以允许用户选择其他排序顺序,因为目前重置它的唯一方法是注销并重新输入。
例子:
当用户按 A 列排序,然后按 B 列排序(反之亦然)时,并且考虑到我正在使用 sortPriority
属性也是如此(这是我无法更改的要求),当当前会话打开时,一对 AB 组合将被锁定。当用户只需要按一列对 DataTable 进行排序(按 A 或 B 排序)时,在进行多列排序后不可能在同一会话中获得此结果。
有什么方法可以实现我需要的“组合列排序发布”吗?
提前致谢。
更新:
我发现数据表中只有两个数据列,唯一的方法是通过在 "Multi"
和 " 之间切换 sortMode
属性单个”
值。这样我就可以保证在单列排序模式下会释放列的组合。
有没有人成功地处理过必须在运行时使用 javascript 为 rich:dataTable
组件属性赋值的情况?
Currently I'm developing a project (JSF 2.0, RichFaces 3.3.3) in which I have to get a 2-columns DataTable with multiple column sorting enabled (I've done this already via sortMode="Multi"
property) but, unlike single column sorting, in the case of multiple columns is impossible for me to release the column or columns for which the sorting is being performed (this is done in single column case by clicking on other column header).
The sort order gets locked during the session: even when switching between tabs, my web application is maintaining the current columns sorting settings. I need to restore this configuration within the session to allow the user to select other sort order, because at present the only way to reset it is to log off and re-enter.
Example:
When the user makes a sorting by column A and then by column B (or vice-versa), and given that I'm using sortPriority
property too (it's a requirement I can't change), the couple A-B combination gets locked while current session is open. When the user needs to sort the DataTable by only one column (sort by either A or B) it's impossible to get this in the same session after making a multi-column sorting.
Is there some way to achieve the "combined-column-sort release" I need?
Thanks in advance.
UPDATE:
I figured out that with only two data columns in my datatable the only way to do this is by toggling somehow the sortMode
property between "Multi"
and "Single"
values. In such a way, I could guarantee that being in the single-column sorting mode it will release the combination of columns.
Has anyone worked successfully with the situation of having to assign values to rich:dataTable
component properties in runtime with javascript?
发布评论
评论(1)
查看 sortBy 和
sortOrder
属性;cid=1272202" rel="nofollow">rich:dataTable
和rich:column
。通过在rich:column
上设置sortOrder="UNSORTED"
,它应该清除该列的排序。您还可以在rich:dataTable
本身上设置sortOrder="UNSORTED"
和/或sortBy=""
以获得更简单的解决方案(虽然我还没有尝试过)。您可以在 JavaScriptonLoad
函数中或在将属性绑定到其属性的 bean 中执行此操作。这应该比使用
sortMode
更优雅一点:)Check out the
sortBy
andsortOrder
attributes ofrich:dataTable
andrich:column
. By settingsortOrder="UNSORTED"
on therich:column
it should clear the sorting of that column. You may also be able to setsortOrder="UNSORTED"
and/orsortBy=""
on therich:dataTable
itself for a simpler solution (although I haven't tried it). You could do this in the JavaScriptonLoad
function or in a bean that has the attributes bound to its properties.That should hopefully be a little more elegant than having to play with the
sortMode
:)