可编辑的数据表RowKey为空 [英] Editable Datatable RowKey Null

查看:312
本文介绍了可编辑的数据表RowKey为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可编辑的Primefaces数据表,该表配置为在编辑单元格时调用onCellEdit()方法.除了CellEditEvent.rowKey始终为null之外,其他一切工作都很好,尽管已使用'rowKey ='在Datatable声明中将其显式设置为有效值. Primefaces数据表文档使我相信我需要rowKey来获取包含正在编辑的单元格的行的内容.我需要整个行的内容,因此我可以将显示的数据与数据库中的相同数据进行比较,以确定自从呈现数据表以来,持久化数据是否已被另一个客户端更改,从而捕获并发编辑.

I have an editable Primefaces Datatable configured to call an onCellEdit() method when a cell is edited. Everything works great except that CellEditEvent.rowKey is always null in spite of setting it explicitly to a valid value in the Datatable declaration with 'rowKey='. The Primefaces Datatable documentation leads me to believe that I need the rowKey to get the contents of the row containing the cell being edited. I need the entire row's contents so I can compare the displayed data with the same data in the database to determine if the persisted data had been changed by another client since the Datatable was rendered, catching concurrent edits.

推荐答案

阅读了rowKey上有空行可选择的数据表的null键之后,我终于意识到rowKey是在行选择而不是单元格编辑中填充的.但是,rowIndex在单元格编辑中不为null,并且可靠地为我提供了行号(从零开始),因此我可以检索整行的内容以及用于填充行的对象的值(在我的情况下包括我想从Datatable.getValue()放入rowKey的值. (对我来说)rowKey的目的在文档中不清楚,所以我想与任何遇到类似问题的人分享.

After reading a dozen or more posts on the rowKey being null with row-selectable Datatables I finally realized that rowKey is populated on row select, not on cell edit. rowIndex, however, is not null on cell edit, and reliably gives me the row number (zero-based) so I can retrieve the entire row's contents, and the values of the object used to populate the row (which in my case includes the value I wanted to put into rowKey) from Datatable.getValue(). The purpose of rowKey is not clear in the documentation (to me), so I thought I would share this for anyone encountering a similar problem.

这篇关于可编辑的数据表RowKey为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆