0

I have a tableview where user can double click on a column row & Combo Box drop down will appear with list of items. Here problem is user can only select one value at a time instead I want to allow user to select multiple values.

Existing Implementation using ComboBoxTableCell

List<TableColumn<DITComparatorFileColumnConfigDO, ?>> columnList = new ArrayList<TableColumn<DITComparatorFileColumnConfigDO, ?>>();
TableColumn<DITComparatorFileColumnConfigDO, String> column = null;

column.setCellValueFactory(new PropertyValueFactory<DITComparatorFileColumnConfigDO, String>("primaryColumn"));
column.setCellFactory(ComboBoxTableCell.forTableColumn(FXCollections.observableArrayList(primaryFileHeaders)));
columnList.add(column);

[enter image description here]

Existing Implementation using ChoiceBoxTableCell

column.setCellValueFactory(new PropertyValueFactory<DITComparatorFileColumnConfigDO, String>("secondaryColumn"));    
column.setCellFactory(ChoiceBoxTableCell.forTableColumn(FXCollections.observableArrayList(secondaryFileHeaders)));
columnList.add(column);

enter image description here

c0der
  • 18,467
  • 6
  • 33
  • 65
  • Possible duplicate of [Selecting multiple items from combobox](https://stackoverflow.com/questions/26186572/selecting-multiple-items-from-combobox) – Elarbi Mohamed Aymen Mar 29 '18 at 11:25
  • I have gone through ControlFX 'checkComboBox' component earlier. It will be helpful if it is used outside tableview but I want it inside table cell factory. Please see the link to application screenshot. – Husain Bata Mar 29 '18 at 11:32
  • https://stackoverflow.com/questions/49543019/adding-and-selecting-choicebox-thats-inside-a-tableview/49543306?noredirect=1#comment86102795_49543306 – Elarbi Mohamed Aymen Mar 29 '18 at 11:40
  • I have already tried with ChoiceBoxTableCell and it allows selecting one value at a time. I am also adding the implementation and screenshot – Husain Bata Mar 29 '18 at 11:44
  • I have updated the question with both implementation. It would be helpful if you can demonstrate an example of selecting multiple values inside tableview cell – Husain Bata Mar 29 '18 at 11:50
  • 1
    You have to write your own table cell implementation that incorporates a `CheckComboBox`. No-one is going to do that for you: try it and if you get stuck post a specific question here. – James_D Mar 29 '18 at 12:12
  • selecting multiple values is not supported by ChoiceBox nor ComboBox – kleopatra Mar 29 '18 at 12:48
  • it is not supported that why I am asking for the solution!!! That doen't mean to devote. – Husain Bata Mar 29 '18 at 12:55
  • where did you get the impression that this site is for _doing_ your work for you? It's all about _helping_ you to come up with a solution .. – kleopatra Mar 29 '18 at 13:49
  • I am not asking to complete my code and give me ready made solutions. I have done lot of research and different approach to get the application up which you can see in screenshots. I am a beginner, instead devoting you can show some alternate path. I appreciate @James_D and I am trying to create custom cell factory. – Husain Bata Mar 30 '18 at 11:57
  • I am trying to figure out this same thing, but there seems to be VERY LITTLE of this one the internet. I am not sure why this got down voted... The answer seems very heavy handed. Is there not an easier way to accomplish this? – Travis Tubbs Sep 04 '18 at 20:09

1 Answers1

1

I have implemented TurekBot CheckComboBoxTableCell which uses ComboBoxTableCell and CellUtils implementations by replacing checkBox to contolFX checkComboBox in it's original file.

Link to solution

Screenshot from my application

  • Your solution is pretty good, but it would be a WHOLE lot better if it could return the selected bound object rather than just a string. What would it take to do that? I have tried modifying it to get that functionality but i am having trouble. – Travis Tubbs Oct 10 '18 at 13:57