0

我想创建具有布尔数据类型的可编辑单元格。

我不想将选择单元用于布尔数据类型

我的 testBooleanColumn 列的单元格包含值为 true、false 的字符串............

当我单击 testBooleanColumn 中存在的单元格时,该单元格应该是可编辑的,并且在该可编辑单元格中,我想显示具有值(true,false)的选择单元格。当用户从 selectioncell 更改值时,无论是 true 还是 false,该值设置为 testBooleanColumn 中的可编辑单元格

这个怎么做?任何提示?或此用例的示例代码?

4

1 回答 1

1

There are three ways to do that:

  1. Use a CompositeCell with an ClickTextCell and a SelectionCell and override the render method of the CompositeCell to render only the ClickTextCell.
    When the ClickTextCell is clicked it will automatically call the ValueUpdater.
    In the update function of the ValueUpdater you have to set some boolean value in your ClickTextCell. Then you have to check in the render method of your CompositeCell this boolean value and if it is set, then render the SelectionCell instead of the ClickTextCell.

  2. Create a custom cell extending AbstractEditableCell for example (see this tutorial) and implement the functionality yourself. You can check out the code for SelectionCell and EditTextCell and copy most of it. Basically you have to have some kind of a flag which is set when the cell gets focus. In the render method you have to either display a dropdownlist or just a text.

  3. Extend either EditTextCell or SelectionCell and implement the missing functionality. The advantage is that you can probably re-use some of the render methods and you don't have to write the complete render code yourself.

于 2011-11-04T12:57:15.020 回答