AsirC
AsirC

Reputation: 459

How to disable the reordering of table columns in tableView?

Trying to figure out on how can i disable the reordering of table columns in javafx 2?

Upvotes: 5

Views: 5338

Answers (2)

rudsly
rudsly

Reputation: 31

After much waste of time, I've found the following, very simple, solution:

TableHeaderRow header = (TableHeaderRow) myTableView.lookup("TableHeaderRow");
header.setMouseTransparent(true);

Upvotes: 3

AsirC
AsirC

Reputation: 459

Here's the solution:

tblView.getColumns().addListener(new ListChangeListener() {
        @Override
        public void onChanged(Change change) {
          change.next();
          if(change.wasReplaced()) {
              tblView.getColumns().clear();
              tblView.getColumns().addAll(column1,column2...);
          }
        }
    });

Upvotes: 9

Related Questions