Richfaces ExtendedDataTable选择问题

Osw*_*Osw 1 jsf richfaces jsf-2

请帮忙.看看http://richfaces-showcase.appspot.com/richfaces/component-sample.jsf?demo=extendedDataTable&sample=exTableSelection&skin=blueSky

你会看到很好的"汽车市场"表,有多种选择支持.您还会注意到所选行之一以粗体显示.这条粗线意味着什么?它是通过某种方法org.richfaces.component.UIExtendedDataTable或任何其他RF类进行管理的吗?无法找到该行的API.

我正在尝试做的是在backing bean中创建新项目并强制表选择指向新创建的项目.我已设法通过设置选择setSelection(),但我无法控制该粗线,它仍保留在它之前的位置,请帮助.

Ken*_*han 5

所选行的粗体样式由richfaces附带的样式表管理.富脸中的每个主题都有自己的样式表.您可以参考官方文档(它仍然是草稿版本)来查看哪些样式类可用于自定义外观rich:extendedDataTable.

例如,rf-edt-r-sel或者rf-edt-r-act定义所选行的样式,您可以通过在您使用的页面中为这些样式类名称声明样式来覆盖它们rich:extendedDataTable

<style type="text/css">
.rf-edt-r-sel{
     background-color: yellow;
}

.rf-edt-r-act{
   font-weight: bold;    
   color: red;
}   
</style>
Run Code Online (Sandbox Code Playgroud)

回复评论:

RowKey似乎是扩展表的行数.如果InventoryItem要从中获取基础对象(即),则UIExtendedDataTable必须setRowKey(selectionKey)在调用getRowData()获取实际对象之前设置要检索的行号.因此,dataTable.setRowKey(selectionKey)用于获取所选择InventoryItemUIExtendedDataTable为了把它们放到selectionItems(将显示在"选定行"复选框即除了扩展表).对于目的Object originalKey = dataTable.getRowKey();dataTable.setRowKey(originalKey);,你可以参考这个链接.

在richfaces 3.3中,我找到UIExtendedDataTable了一个名为setActiveRowKey()的方法,它似乎可以设置活动记录.但是在最新版本的richfaces 4.0 CR1中删除了它.所以你可以使用UIExtendedDataTable java脚本API来达到同样的效果.

首先定义MBean中int调用的属性boldRow.然后你将有一个<a4j:commandButton>调用Mbean的方法.这个方法将根据你的逻辑分配你想要选择的行号.该oncomplete按钮的属性应该调用UIExtendedDataTable的JavaScript API来选择行号等于的行boldRow,然后使用render属性刷新UIExtendedDataTable.所以<a4j:commandButton>,<rich:extendedDataTable> 应该看起来像这样:

 <a4j:commandButton value="Submit" action = "#{MBean.action}" render="#{rich:clientId('table')}"  
           oncomplete="#{rich:component('table')}.selectRow(#{MBean.boldRow}); #{rich:component('table')}.setActiveRow(#{MBean.boldRow});" />

<rich:extendedDataTable id="table" .....
................
</rich:extendedDataTable>
Run Code Online (Sandbox Code Playgroud)