Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evgen2sat/jfxtableview
Advanced JavaFx TableView with filtering and total functions
https://github.com/evgen2sat/jfxtableview
javafx javafx-components javafx-tableview tablefilter tableview
Last synced: 3 months ago
JSON representation
Advanced JavaFx TableView with filtering and total functions
- Host: GitHub
- URL: https://github.com/evgen2sat/jfxtableview
- Owner: Evgen2sat
- License: bsd-3-clause
- Created: 2020-09-08T07:34:56.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-02-18T05:36:01.000Z (about 3 years ago)
- Last Synced: 2023-07-04T02:14:03.064Z (over 1 year ago)
- Topics: javafx, javafx-components, javafx-tableview, tablefilter, tableview
- Language: Java
- Homepage:
- Size: 922 KB
- Stars: 10
- Watchers: 4
- Forks: 2
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://maven-badges.herokuapp.com/maven-central/io.github.evgen2sat/JFXTableView)
# JFXTableView
Advanced JavaFx TableView with filtering and total functions.## Description
The implementation of the filter is easy. You wrap your `TableView` with the `JFXTableView`
and add the columns which wrap `JFXTableColumn`.There are the following column implementations:
* `JFXBooleanTableColumn`
* `JFXDoubleTableColumn`
* `JFXFloatTableColumn`
* `JFXIntegerTableColumn`
* `JFXLocalDateTableColumn`
* `JFXLocalDateTimeTableColumn`
* `JFXLocalTimeTableColumn`
* `JFXLongTableColumn`
* `JFXStringTableColumn`
* `JFXBigDecimalTableColumn`You can create your own column implementation by inheriting from the abstract `JFXTableColumn` class.
You can turn off filtering on a table by passing `false` to the `setAllowFiltering` method. Example:
```
jfxTableView.setAllowFiltering(false);
```The following types of filtering are supported (The filter types available depend on the choice of the `JFXTableColumn` implementation):
* `Equals`
* `Not equals`
* `Greather or equals than`
* `Greather than`
* `Less or equals than`
* `Less than`
* `Start with`
* `End with`
* `Contains`
* `Not contains`
* `Regular expression`
* `Custom filtering`The following types of column totals are supported (The totals types available depend on the choice of the `JFXTableColumn` implementation):
* `Sum`
* `Minimum`
* `Maximum`
* `Average`## Features
JFXTableView supports the following features:* Filtering rows by columns (multiple filter option with `Custom filtering` by column)
* Totals by column
* Count rows
* Copy cell value from context menu
* Export to file
* Localization and internationalization## Get Started
Create table `JFXTableView` and columns `JFXTableColumn`:```
//custom model for JFXTableView
class Model {
private SimpleBooleanProperty boolValue = new SimpleBooleanProperty();
private SimpleDoubleProperty doubleValue = new SimpleDoubleProperty();
private SimpleFloatProperty floatValue= new SimpleFloatProperty();
private SimpleIntegerProperty integerValue = new SimpleIntegerProperty();
private SimpleLongProperty longValue = new SimpleLongProperty();
private SimpleStringProperty stringValue = new SimpleStringProperty();
private SimpleObjectProperty localDateValue = new SimpleObjectProperty<>();
private SimpleObjectProperty localDateTimeValue = new SimpleObjectProperty<>();
private SimpleObjectProperty localTimeValue = new SimpleObjectProperty<>();
//getters and setters
}//initialize JFXTableView
//background is StackPane (usually this is Node on which the controls are located in the scene), which is necessary for the darkening effect when opening dialog boxes
JFXTableView jfxTableView = new JFXTableView<>(background);//initialize JFXTableColumns
JFXTableColumn boolColumn = new JFXBooleanTableColumn<>("Bool value");
boolColumn.setCellValueFactory(new PropertyValueFactory<>("boolValue"));JFXTableColumn doubleColumn = new JFXDoubleTableColumn<>("Double value");
doubleColumn.setCellValueFactory(new PropertyValueFactory<>("doubleValue"));JFXTableColumn floatColumn = new JFXFloatTableColumn<>("Float value");
floatColumn.setCellValueFactory(new PropertyValueFactory<>("floatValue"));JFXTableColumn integerColumn = new JFXIntegerTableColumn<>("Integer value");
integerColumn.setCellValueFactory(new PropertyValueFactory<>("integerValue"));JFXTableColumn longColumn = new JFXLongTableColumn<>("Long value");
longColumn.setCellValueFactory(new PropertyValueFactory<>("longValue"));JFXTableColumn localDateColumn = new JFXLocalDateTableColumn<>("LocalDate value");
localDateColumn.setCellValueFactory(new PropertyValueFactory<>("localDateValue"));JFXTableColumn localDateTimeColumn = new JFXLocalDateTimeTableColumn<>("LocalDateTime value");
localDateTimeColumn.setCellValueFactory(new PropertyValueFactory<>("localDateTimeValue"));JFXTableColumn localTimeColumn = new JFXLocalTimeTableColumn<>("LocalTime value");
localTimeColumn.setCellValueFactory(new PropertyValueFactory<>("localTimeValue"));JFXTableColumn stringColumn = new JFXStringTableColumn<>("String value");
stringColumn.setCellValueFactory(new PropertyValueFactory<>("stringValue"));//add columns to JFXTableView
jfxTableView.getColumns().addAll(boolColumn, doubleColumn, floatColumn, integerColumn, longColumn,
localDateColumn, localDateTimeColumn, localTimeColumn, stringColumn);//initialize data
ObservableList data = FXCollections.observableArrayList();
Model row1 = new Model();
row1.setBoolValue(true);
row1.setDoubleValue(1);
row1.setFloatValue(2);
row1.setIntegerValue(3);
row1.setLocalDateTimeValue(LocalDateTime.now());
row1.setLocalDateValue(LocalDate.now());
row1.setLocalTimeValue(LocalTime.now());
row1.setLongValue(4);
row1.setStringValue("string");
data.add(row1);//set data to JFXTableView
jfxTableView.setData(data);
```Result:
`background` is StackPane (usually this is Node on which the controls are located in the scene), which is necessary for the darkening effect when opening dialog boxes. For example with shadow:

Without shadow:

## Numbered rows
First column used for display numbered rows. Unvisible by default, use setVisibleNumberedRowsColumn method for table.```
//set visible numbered rows column for JFXTableView
jfxTableView.setVisibleNumberedRowsColumn();
```## Export to file
First (or second if numbered rows visible) column have burger menu button. Use popup action for export data to file.By default export data to CSV file, but you can write your own implementation and pass a reference to the method in `jfxTableView.setExportDataAction` (To get data from the table use the `jfxTableView.getDataForExport()` method).
## Localization and internationalization
For localization and internationalization use Resource bundle `message`. Available by default `en` and `ru_RU`.## Credits
* [FontAwesomeFX](https://bitbucket.org/Jerady/fontawesomefx)
* [JFoenix](https://github.com/jfoenixadmin/JFoenix)
* [RxJava](https://github.com/ReactiveX/RxJava)