Skip to content

Commit 9cd5683

Browse files
committed
Resolve issues with the InfiniteDataTableView.
1 parent c1ded8a commit 9cd5683

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/main/java/gwt/material/design/demo/client/application/datatable/infinite/InfiniteDataTableView.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,27 @@ interface Binder extends UiBinder<Widget, InfiniteDataTableView> {
5252
// we are faking the service on the client side to avoid requiring a web server.
5353
private PersonServiceAsync personService = GWT.create(FakePersonService.class);
5454

55-
@UiField
55+
@UiField(provided = true)
5656
MaterialInfiniteDataTable<Person> table;
5757

5858
@Inject
5959
InfiniteDataTableView(Binder uiBinder) {
60+
table = new MaterialInfiniteDataTable<>(20,
61+
InfiniteDataView.DYNAMIC_VIEW, new PersonDataSource(personService));
62+
6063
initWidget(uiBinder.createAndBindUi(this));
64+
}
65+
66+
@Override
67+
protected void onAttach() {
68+
super.onAttach();
69+
70+
table.getTableTitle().setText("Infinite Table");
71+
72+
table.clearRowsAndCategories(true);
73+
74+
// Load the categories from the server
75+
table.getView().setLoadMask(true);
6176

6277
personService.getCategories(new AsyncCallback<List<String>>() {
6378
@Override
@@ -73,23 +88,6 @@ public void onFailure(Throwable throwable) {
7388
}
7489
});
7590

76-
table = new MaterialInfiniteDataTable<>(20,
77-
InfiniteDataView.DYNAMIC_VIEW, new PersonDataSource(personService));
78-
}
79-
80-
@Override
81-
protected void onAttach() {
82-
super.onAttach();
83-
84-
loadDataTable();
85-
}
86-
87-
protected void loadDataTable() {
88-
table.getTableTitle().setText("Infinite Table");
89-
// Load the categories from the server
90-
table.getView().setLoadMask(true);
91-
92-
9391
// Add an image profile on each category rows
9492
table.addColumn(new WidgetColumn<Person, MaterialImage>() {
9593
@Override
@@ -165,10 +163,10 @@ public String getValue(Person object) {
165163

166164
@UiHandler("cbCategories")
167165
void onCategories(ValueChangeEvent<Boolean> e) {
168-
if(e.getValue()){
166+
if(e.getValue()) {
169167
table.setUseCategories(true);
170168
GWT.log("Categories checked");
171-
}else{
169+
} else {
172170
table.setUseCategories(false);
173171
GWT.log("Categories not checked");
174172
}

0 commit comments

Comments
 (0)