I want to select specific index in my e.g tableview.index(0).getSelectedItem(); something like this. I did it but I can only select the last row. something like selectLast(); quiet similar to what I wanna do. How to do that in javafx, I'm quiet beginner to this language hopefully I did point out what I'm trying to say.
Asked
Active
Viewed 561 times
1 Answers
3
tableView.getSelectionModel().select(index);
The above code will select the index you wish to select.
tableView.getSelectionModel().getSelectedItem();
And the above code will return you the item at the index.
-
I didn't work for me, I want to it select specific index programmatically. Lets say i want to select the row 5 in my table whenever my program starts.. just like what this syntax " receiptTableView.getSelectionModel().selectLast();" – Raymond Cañete Apr 18 '18 at 06:02
-
hey mate thankyou i just a code like this and its perfectly fine thankyouuuu. receiptTableView.getSelectionModel().select(1); receiptTableView.getSelectionModel().getSelectedItem(); Receipt_List selectedRow = receiptTableView.getSelectionModel().getSelectedItem(); – Raymond Cañete Apr 18 '18 at 06:07
-
@RaymondCañete The first call to `getSelectedItem()` in your comment is unnecessary. Also you don't need to go though the selection model to get an item at a specific index: `receiptTableView.getItems().get(1)` yields the same result as `receiptTableView.getSelectionModel().getSelectedItem();` – fabian Apr 18 '18 at 07:30