Skip to content

Commit 7849542

Browse files
committed
Resolve issues with InfiniteDataTableView categories checkbox.
1 parent 7040b7c commit 7849542

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

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

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,7 @@ protected void onAttach() {
7171

7272
table.clearRowsAndCategories(true);
7373

74-
// Load the categories from the server
75-
table.getView().setLoadMask(true);
76-
77-
personService.getCategories(new AsyncCallback<List<String>>() {
78-
@Override
79-
public void onSuccess(List<String> categories) {
80-
for(String category : categories) {
81-
table.addCategory(new CategoryComponent(category));
82-
}
83-
table.getView().setLoadMask(false);
84-
}
85-
@Override
86-
public void onFailure(Throwable throwable) {
87-
GWT.log("Getting people categories async call failed.", throwable);
88-
}
89-
});
74+
loadCategories();
9075

9176
// Add an image profile on each category rows
9277
table.addColumn(new WidgetColumn<Person, MaterialImage>() {
@@ -161,17 +146,40 @@ public String getValue(Person object) {
161146
}
162147
}
163148

149+
protected void loadCategories() {
150+
// Load the categories from the server
151+
table.getView().setLoadMask(true);
152+
153+
personService.getCategories(new AsyncCallback<List<String>>() {
154+
@Override
155+
public void onSuccess(List<String> categories) {
156+
for(String category : categories) {
157+
table.addCategory(new CategoryComponent(category));
158+
}
159+
table.getView().setLoadMask(false);
160+
}
161+
@Override
162+
public void onFailure(Throwable throwable) {
163+
GWT.log("Getting people categories async call failed.", throwable);
164+
}
165+
});
166+
}
167+
164168
@UiHandler("cbCategories")
165169
void onCategories(ValueChangeEvent<Boolean> e) {
166170
if(e.getValue()) {
167-
table.setUseCategories(true);
168171
GWT.log("Categories checked");
172+
173+
table.setUseCategories(true);
174+
table.clearRowsAndCategories(true);
175+
loadCategories();
169176
} else {
170-
table.setUseCategories(false);
171177
GWT.log("Categories not checked");
178+
179+
table.setUseCategories(false);
180+
table.getView().setRedraw(true);
181+
table.getView().refresh();
172182
}
173-
table.getView().setRedraw(true);
174-
table.getView().refresh();
175183
}
176184

177185
private void updateSelectedRows(int size) {

0 commit comments

Comments
 (0)