fix results display
This commit is contained in:
parent
16161d5c9d
commit
4c983291ac
|
@ -10,6 +10,7 @@ import javafx.scene.Node;
|
|||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -22,11 +23,14 @@ public class SearchController {
|
|||
@FXML
|
||||
private Button searchButton;
|
||||
@FXML
|
||||
private Pagination pagination;
|
||||
@FXML
|
||||
private Label searchLabel;
|
||||
@FXML
|
||||
private TableView tableView;
|
||||
@FXML
|
||||
private VBox dataContainer;
|
||||
|
||||
private ObservableList<Person> masterData = FXCollections.observableArrayList();
|
||||
private ObservableList<Person> results = FXCollections.observableList(masterData);
|
||||
|
||||
public SearchController() {
|
||||
masterData.add(new Person(5, "John", true));
|
||||
|
@ -52,22 +56,21 @@ public class SearchController {
|
|||
searchLabel.setText(newValue);
|
||||
});
|
||||
|
||||
pagination.setPageFactory(SearchController.this::createPage);
|
||||
initTable();
|
||||
|
||||
}
|
||||
|
||||
private Node createPage(Integer pageIndex) {
|
||||
|
||||
VBox dataContainer = new VBox();
|
||||
|
||||
TableView<Person> tableView = new TableView<>(masterData);
|
||||
private void initTable() {
|
||||
tableView = new TableView<>(FXCollections.observableList(masterData));
|
||||
TableColumn id = new TableColumn("ID");
|
||||
id.setCellValueFactory(new PropertyValueFactory("id"));
|
||||
TableColumn name = new TableColumn("NAME");
|
||||
name.setCellValueFactory(new PropertyValueFactory("name"));
|
||||
TableColumn employed = new TableColumn("EMPLOYED");
|
||||
employed.setCellValueFactory(new PropertyValueFactory("isEmployed"));
|
||||
|
||||
tableView.getColumns().addAll(id, name, employed);
|
||||
dataContainer.getChildren().add(tableView);
|
||||
|
||||
return dataContainer;
|
||||
}
|
||||
|
||||
private void loadData() {
|
||||
|
@ -86,9 +89,8 @@ public class SearchController {
|
|||
};
|
||||
|
||||
task.setOnSucceeded(event -> {
|
||||
masterData = task.getValue();
|
||||
pagination.setVisible(true);
|
||||
pagination.setPageCount(masterData.size() / PAGE_ITEMS_COUNT);
|
||||
results = task.getValue();
|
||||
tableView.setItems(FXCollections.observableList(results));
|
||||
});
|
||||
|
||||
Thread th = new Thread(task);
|
||||
|
|
|
@ -21,13 +21,12 @@
|
|||
</children>
|
||||
</HBox>
|
||||
|
||||
<Pagination fx:id="pagination"
|
||||
<VBox fx:id="dataContainer"
|
||||
AnchorPane.leftAnchor="10.0"
|
||||
AnchorPane.rightAnchor="10.0"
|
||||
AnchorPane.topAnchor="50.0"
|
||||
visible="false">
|
||||
AnchorPane.topAnchor="50.0">
|
||||
|
||||
</Pagination>
|
||||
</VBox>
|
||||
|
||||
</children>
|
||||
</AnchorPane>
|
Loading…
Reference in New Issue