【问题标题】:What is the use of the rowKey attribute in Primefaces' p:dataTable?Primefaces 的 p:dataTable 中的 rowKey 属性有什么用?
【发布时间】:2013-09-22 18:03:36
【问题描述】:

我尝试在 p:dataTable 中选择行,但它显示错误。在我为p:dataTablerowKey 属性添加值后,错误得到纠正。因此我想知道rowKey 属性的实际用途是什么。

【问题讨论】:

    标签: jsf-2 primefaces primefaces-extensions


    【解决方案1】:

    我引用 PrimeFaces 参考指南:

    RowKey 应该是数据模型中的唯一标识符,并由数据表用于查找选定的行。您可以通过以下方式定义此密钥 使用 rowKey 属性或通过绑定实现的数据模型 org.primefaces.model.SelectableDataModel。

    因此,如果您的数据表是由 bean 集合设置的,则 rowKey 应该是唯一表示该 bean 的属性,例如表示数据库主键的属性。

    【讨论】:

      猜你喜欢
      • 2019-01-12
      • 2017-06-08
      • 2019-05-19
      • 2015-07-24
      • 2014-01-29
      • 2014-05-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多