-
Notifications
You must be signed in to change notification settings - Fork 0
How to use FilteredTableView
chqu1012 edited this page Oct 29, 2019
·
2 revisions
Create a Controller class, to populate the tableview use the setInput method indeed setItems!
import java.lang.reflect.Field;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import de.dc.entity.lang.templates.core.control.filtered.tableview.FilteredTableView;
import de.dc.fx.entity.contact.model.Contact;
import de.dc.fx.entity.contact.repository.ContactRepository;
import javafx.collections.FXCollections;
import javafx.scene.layout.BorderPane;
@Controller
public class ContactFilteredTableView extends BorderPane{
@Autowired ContactRepository repository;
protected FilteredTableView<Contact> filteredTableView = new FilteredTableView<>(FXCollections.observableArrayList());
public ContactFilteredTableView() {
for (Field field : Contact.class.getDeclaredFields()) {
filteredTableView.createColumn(field.getName(), 200);
}
setCenter(filteredTableView);
}
public void init() {
filteredTableView.setInput(FXCollections.observableArrayList(repository.findAll()));
}
}
Add this control to MetroPage
PageContainer{
...
Page ContactFilteredTabePage{
control: de.dc.fx.entity.contact.control.ContactFilteredTableView
}
...
}
Referenced this page into SpringMetro dsl
packagePath de.dc.fx.entity.contact
SpringMetro Contact{
title: "My Application"
subtitle: "Small description for this application"
theme: Flat
navigations: Contact, ContactHistory, EventLog, PreferencePage, MetroContactLogin, MetroPersonPage, CalendarPage,
MetroDarkContactTable, ContactFilteredTabePage
}