Richfaces ExtendedDataTable选择问题

发布于 2024-10-27 11:18:16 字数 574 浏览 1 评论 0原文

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

您会看到漂亮的“汽车市场”表格,支持多项选择。您还会注意到选定的行之一以粗体显示。这条粗线到底是什么意思?它是否通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妄司 2024-11-03 11:18:16

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

例如,rf-edt-r-selrf-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>

回复评论:

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 中定义一个名为 boldRowint 属性。然后您将有一个 来调用 Mbean 的方法。该方法将根据您的逻辑分配您想要选择的行号。按钮的 oncomplete 属性应调用 UIExtendedDataTable 的 JavaScript API 来选择行号等于 boldRow 的行,然后使用render 属性刷新 UIExtendedDataTable。因此 应该看起来像这样:

 <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>

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 or rf-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 use rich:extendedDataTable

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

.rf-edt-r-act{
   font-weight: bold;    
   color: red;
}   
</style>

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 the UIExtendedDataTable , you have to set the row number you want to retrieve using setRowKey(selectionKey) before calling getRowData() to get the actual object . So dataTable.setRowKey(selectionKey) is used to get the selected InventoryItem from the UIExtendedDataTable in order to put them into the selectionItems (which will be displayed in the "Selected Rows" box that is besides the extended table) . For the purposes of Object originalKey = dataTable.getRowKey(); and dataTable.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 the UIExtendedDataTable 's java script API to achieve the same effect .

You first define an int property called boldRow 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. The oncomplete attribute of the button should call the UIExtendedDataTable 's JavaScript API to select a row which row number is equal to boldRow, and then use render attribute to refresh the UIExtendedDataTable. So the <a4j:commandButton> and <rich:extendedDataTable> should probably look like this:

 <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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文