Chetna rustagi
Chetna rustagi

Reputation: 481

Visible columns in Treetableview

In javaFx, treetableView, we can hide or show columns using "+" i.e setTableMenuButtonVisible(true) symbol

say I have 10 columns in treetableview, but i have shown only 5, How can my program get count of only those columns which are visible (i.e 5 in this case)

Upvotes: 0

Views: 109

Answers (2)

Chetna rustagi
Chetna rustagi

Reputation: 481

Thanks Dev for your answer, though tableCol.isVisible method doesnt works for me, but i got it done other way round.

    int count=0;
    for (int j = 0; j < ltpSystemViewer.getTable().getColumnCount(); j++) {
        TableColumn tableCol = ltpSystemViewer.getTable().getColumn(j);
        if (tableCol.getWidth()>0)
            count++;
    }

    return count;

Upvotes: 0

V.Dev
V.Dev

Reputation: 167

U can have something like

ObservableList<TableColumn> visibleColumnList =FXCollections.observableArrayList();

ObservableList<TableColumn > tableColumnList = tableView.getColumns();
for (int j = 0; j < tableColumnList.size(); j++) {
    TableColumn tableCol = tableColumnList.get(j);
    if (tableCol.isVisible())
        visibleColumnList.add(tableCol);
}

Long count = visibleColumnList.size();

Upvotes: 1

Related Questions