B4J Question merge 2 titles on tableview

electro179

Active Member
Licensed User
Longtime User
Hi


Can I merge on 2 titles in the tableview ?

TITLE COL 1 | TITLE COL 2 |
INFO COL 1 | INFO 1 COL 2 | INFO 2 COL 2 |


thank you
 

Daestrum

Expert
Licensed User
Longtime User
If you mean something like attached screenshot. You can do it from the scene builder (2.0).
 

Attachments

  • multicol.png
    multicol.png
    143.4 KB · Views: 272
Upvote 0

electro179

Active Member
Licensed User
Longtime User
for b4j How much there are col ?
Titles 1 is a col ?
Info 1 is a col ?

How to use this tableview in b4J

thank you
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
After some experimenting I think I found why the 'leaf' Table Columns wont work.
When you add them, it basically screws up the cell factories for every cell to their right.
it is possible to get them working in pure java, but not from B4J (yet).

(Erel if the code is useful feel free to use it.)
B4X:
    public void addLeafColumns(TableColumn t, String... names) {
        int i = t.getTableView().getVisibleLeafColumns().indexOf(t);
        for (String a : names) {
            TableColumn x = new TableColumn<>(a);
            x.setCellValueFactory(new TestCellValueFactory(i));
            if (i==0) {
                t.getColumns().add(x);
            }else{
                t.getColumns().add(i, x);
            }
            i++;
        }
        correctCellValueFactory(t.getTableView());
    }
    public void correctCellValueFactory(TableView t) {
        t.getColumns().forEach(
                tc -> {
                    ((TableColumn) tc).setCellValueFactory(
                            new TestCellValueFactory(((TableColumn) tc).getTableView().getVisibleLeafColumns().indexOf(tc)));
                });

    }
just call correctCellValueFactory after adding leaf or normal columns to the table.
 
Last edited:
Upvote 0
Top