Reputation: 83
Fairly simple question: I want to get the row index of the table based on value in a particular column. Lets say the column name is "ID", it has unique values in my TableView.
Now, I want to retrieve the row index where the column "ID" is 22.
I only have access to the TableView object and the column("ID") value with me.
Upvotes: 0
Views: 3397
Reputation: 1
If you want to select row using mouse. Than you can try something like this
tableview.getSelectionModel().getSelectedItem()
Upvotes: -1
Reputation: 1544
Use this code.
for (int i = 0; i < tableView.getItems().size(); i++) {
if (tableView.getItems().get(i).getId() == 22) {
System.out.println("Selected Index : "+i);
}
}
Upvotes: 2