I have created editable grid in which I am adding all the cell widgets. Now I want to check for some condition and replace a cell or column with another cell widget. For example if I have defined a column of EditTextCell, based on a boolean condition I have to change that column to have selectioncells(combo box). How to achieve this?
Share
There are three ways to do that:
Use a
CompositeCellwith anEditTextCelland aSelectionCelland override the render method of theCompositeCellto render either theEditTextCellor theSelectionCellbased on a boolean flag that you store in yourDTOthat is bound to the Cell.Create a custom cell extending
AbstractEditableCellfor example (see this tutorial) and implement the functionality yourself. You can check out the code for SelectionCell and EditTextCell and copy most of it. In the render method you have to either display a dropdownlist or just a text based on the boolean flag.Extend either
EditTextCellorSelectionCelland 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.