Richfaces ExtendedDataTable选择问题
您会看到漂亮的“汽车市场”表格,支持多项选择。您还会注意到选定的行之一以粗体显示。这条粗线到底是什么意思?它是否通过 org.richfaces.component.UIExtendedDataTable 或任何其他 RF 类的方法以某种方式进行管理?找不到该行的 API。
我想做的是在支持 bean 内创建新项目并强制表选择指向新创建的项目。我已成功通过 setSelection()
设置选择,但我无法控制该粗线,它仍保留在之前的位置,请帮忙。
Please help.
Have a look at http://richfaces-showcase.appspot.com/richfaces/component-sample.jsf?demo=extendedDataTable&sample=exTableSelection&skin=blueSky
You'll see nice "Cars marketplace" table with multiple selection support. You'll also notice that one of the selected rows appears in bold. What does this bold line mean at all? Is it managed somehow via methods of org.richfaces.component.UIExtendedDataTable
or any other RF classes? Cant find an API for that line.
What I'm trying to do, is to create new item inside backing bean and force table selection to point to newly created item. I've managed to set selection via setSelection()
, but I have no control over that bold line, it remains on it's previous position, please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所选行的粗体样式由 richfaces 附带的样式表管理。richfaces 中的每个主题都有自己的样式表。您可以参考 官方文档(目前还是草稿版本),查看哪些样式类可用于自定义
rich:extendedDataTable
的外观。例如,
rf-edt-r-sel
或rf-edt-r-act
定义所选行的样式,您可以通过声明这些样式来覆盖它们使用rich:extendedDataTable
的页面中的样式类名回复评论:
RowKey
好像是扩展表的行号。如果您想从UIExtendedDataTable
获取基础对象(即InventoryItem
),您必须使用setRowKey(selectionKey)< 设置要检索的行号。 /code> 在调用
getRowData()
获取实际对象之前。因此,dataTable.setRowKey(selectionKey)
用于从UIExtendedDataTable
中获取选定的InventoryItem
,以便将它们放入selectionItems< /code> (将显示在扩展表旁边的“选定行”框中)。对于
Object originalKey = dataTable.getRowKey();
和dataTable.setRowKey(originalKey);
,您可以参考此 链接 。在richfaces 3.3中,我发现
UIExtendedDataTable
有一个名为setActiveRowKey()的方法,该方法似乎可以设置活动记录。但在最新版本的 richfaces 4.0 CR1 中它被删除了。所以也许你可以使用UIExtendedDataTable
的java脚本API来达到同样的效果。首先在 MBean 中定义一个名为
boldRow
的int
属性。然后您将有一个
来调用 Mbean 的方法。该方法将根据您的逻辑分配您想要选择的行号。按钮的oncomplete
属性应调用UIExtendedDataTable
的 JavaScript API 来选择行号等于boldRow
的行,然后使用render
属性刷新UIExtendedDataTable
。因此
和
应该看起来像这样:The bold style for the selected row is managed by the stylesheet shipped with richfaces .Each theme in the richfaces has their own stylesheet. You can refer to the official documentation ( It is still a draft version) to see which style classes are available for customizing the look and feel of the
rich:extendedDataTable
.For example ,
rf-edt-r-sel
orrf-edt-r-act
define the style of the selected row, you can override them by declaring a style for these style class names in the page where you userich:extendedDataTable
Reply to the comment:
The
RowKey
seems to be the row number of the extended table. If you want to get the underlying object (i.e.InventoryItem
) from theUIExtendedDataTable
, you have to set the row number you want to retrieve usingsetRowKey(selectionKey)
before callinggetRowData()
to get the actual object . SodataTable.setRowKey(selectionKey)
is used to get the selectedInventoryItem
from theUIExtendedDataTable
in order to put them into theselectionItems
(which will be displayed in the "Selected Rows" box that is besides the extended table) . For the purposes ofObject originalKey = dataTable.getRowKey();
anddataTable.setRowKey(originalKey);
, you can refer to this link .In richfaces 3.3 , I find
UIExtendedDataTable
has a method called setActiveRowKey() , which seems can set the active record . But it is removed in the latest version of richfaces 4.0 CR1 .So maybe you can use theUIExtendedDataTable
's java script API to achieve the same effect .You first define an
int
property calledboldRow
in your MBean . Then you will have a<a4j:commandButton>
to call a Mbean 's method .This method will assign the row number that you want to select according to your logic. Theoncomplete
attribute of the button should call theUIExtendedDataTable
's JavaScript API to select a row which row number is equal toboldRow
, and then userender
attribute to refresh theUIExtendedDataTable
. So the<a4j:commandButton>
and<rich:extendedDataTable>
should probably look like this: