Mohammad Sadiq Shaikh
Mohammad Sadiq Shaikh

Reputation: 3200

Search operation in javafx tableview

I used the tutorial on link TUTORIAL LINK

Now I want to perform the search operation on tableview to search for table row contents to match the query.

So is there any way to to search for items in tableview.

Something I found in c# was the LINQ query which search in the list for condition.

Is there something similar in javafx.

Upvotes: 0

Views: 4798

Answers (4)

muhamad
muhamad

Reputation: 1

1) Get your TableView object
2) Call getItems() method on it
3) Call get() method the parameter for this method is the index of your object

TableView<String> tableView = new TableView<>();
Now, suppose that we've already filled tableView with Products objects
You can reach to every object this way
tableView.getItems().get(0)
This will return the first object you added to tableView

I Hope This Helps ^_^

Upvotes: 0

Az Ad
Az Ad

Reputation: 3

this is search method, where data is your list ,

 private boolean search(String a ){
 int i=0;
 do{
    if(data.get(i).getNom().equals(a) )
    {
        return true;

    }
    i++;
 }while(data.size()>i);
    return false;}

Upvotes: 0

Marc Rasmussen
Marc Rasmussen

Reputation: 20555

I saw a project like this once.

Maybe this is what your looking for: Advanced TableView

Sadly i have no idea how they implemented it.

EDIT The page i linked to states that you should go to the following page: TiwulFX

Upvotes: 1

Alexander Kirov
Alexander Kirov

Reputation: 3654

Seems, there is nothing similar. You can file a RFE, or a Tweak, in JavaFX-2 jira, if you want to have such functionality (if it doesn't exist yet).

Or, if you know, how should it look like, you can talk to author of TableView, and implement it by yourself, and push according patch in an open javafx.

Practically, you can do a search over a collection of content of TableView, and apply value factory of each column for according value, and check, if it returns an appropriate value/content.

Upvotes: 1

Related Questions