I have a customized TableView defined in an FXML and the table works fine so far. The code is something like the followings:
<FitWidthTableView fx:id="dataDisplayView" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="300.0" prefWidth="380.0" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="rowColumn" maxWidth="50.0" prefWidth="30.0" sortable="false" style="-fx-alignment: CENTER_RIGHT;" text="Row" />
...
</FitWidthTableView>
Now, I need to add the Pagination due to a huge amount of data (from a DB). It would be great if I can wrap around the TableView tag with the Pagination tag. I find a sample with the approach as the following
<Pagination fx:id="pagination" layoutX="2.0" layoutY="188.0" prefHeight="275.0" prefWidth="912.0">
<fx:define>
<FitWidthTableView fx:id="dataDisplayView" maxHeight="1.7976931348623157E308"
maxWidth="1.7976931348623157E308" prefHeight="300.0" prefWidth="380.0"
VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="rowColumn" maxWidth="50.0" prefWidth="30.0" sortable="false"
style="-fx-alignment: CENTER_RIGHT;" text="Row"/>
...
</columns>
<VBox.margin>
<Insets left="1.0" right="1.0"/>
</VBox.margin>
</FitWidthTableView>
</fx:define>
</Pagination>
while almost all examples of TableView with Pagination are done without FXML.
I, however, don't see the pagination controller code sample which shall do a few things: determine the number of pages, specify the page size, and populate data to the table. Can someone advise on the subject?
My controller is something like the followings:
public class DataViewerController implements Initializable {
@FXML
private Pagination pagination ;
@FXML
private FitWidthTableView<OutputData> dataDisplayView;
@FXML
private TableColumn<OutputData, Integer> rowColumn;
…
@Autowired
private OutputDataRepository outputDataRepository;
@Override // This method is called by the FXMLLoader when initialization is complete
@FXML
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
…
}
…
}
How to populate data with the above code structure?