Skip to content

Commit 18f39e0

Browse files
committed
Fix more loading issues with the data table samples.
1 parent 7849542 commit 18f39e0

File tree

5 files changed

+19
-79
lines changed

5 files changed

+19
-79
lines changed

src/main/java/gwt/material/design/demo/client/application/datatable/contextmenu/ContextMenuDataTableView.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,7 @@ interface Binder extends UiBinder<Widget, ContextMenuDataTableView> {
6363
@Inject
6464
ContextMenuDataTableView(Binder uiBinder) {
6565
initWidget(uiBinder.createAndBindUi(this));
66-
}
67-
68-
@Override
69-
protected void onAttach() {
70-
super.onAttach();
71-
72-
loadDataTable();
73-
}
7466

75-
protected void loadDataTable() {
7667
// We will manually add this category otherwise categories
7768
// can be loaded on the fly with HasDataCategory, or a custom
7869
// RowComponentFactory as demonstrated below
@@ -174,7 +165,7 @@ public MaterialBadge getValue(Person object) {
174165
// Generate 20 categories
175166
int rowIndex = 0;
176167
List<Person> people = new ArrayList<>();
177-
for(int k = 1; k <= 5; k++){
168+
for(int k = 1; k <= 2; k++){
178169
// Generate 100 rows
179170
for(int i = 1; i <= 10; i++, rowIndex++){
180171
people.add(new Person(i, "http://joashpereira.com/templates/material_one_pager/img/avatar1.png", "Field " + rowIndex, "Field " + i, "Field " + rowIndex, "No " + i,"Category " + k)); }

src/main/java/gwt/material/design/demo/client/application/datatable/custom/CustomDataTableView.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,7 @@ interface Binder extends UiBinder<Widget, CustomDataTableView> {
5757
@Inject
5858
CustomDataTableView(Binder uiBinder) {
5959
initWidget(uiBinder.createAndBindUi(this));
60-
}
61-
62-
@Override
63-
protected void onAttach() {
64-
super.onAttach();
65-
66-
loadDataTable();
67-
}
6860

69-
protected void loadDataTable() {
7061
// TODO Issue with the onload / unload update
7162
/*// Setting table title
7263
table.getTableTitle().setText("My Custom Table");

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,6 @@ interface Binder extends UiBinder<Widget, InfiniteDataTableView> {
6161
InfiniteDataView.DYNAMIC_VIEW, new PersonDataSource(personService));
6262

6363
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-
loadCategories();
7564

7665
// Add an image profile on each category rows
7766
table.addColumn(new WidgetColumn<Person, MaterialImage>() {
@@ -137,13 +126,17 @@ public String getValue(Person object) {
137126
updateSelectedRows(table.getSelectedRowModels(false).size());
138127
GWT.log("Selected["+event.isSelected()+"]: " + event.getModels().size() + " models");
139128
});
129+
}
140130

141-
if(!table.isUseCategories()) {
142-
// Since we aren't using categories for this table
143-
// we will forcefully invoke a table refresh that
144-
// sends a request for data.
145-
table.getView().refresh();
146-
}
131+
@Override
132+
protected void onAttach() {
133+
super.onAttach();
134+
135+
table.getTableTitle().setText("Infinite Table");
136+
137+
table.clearRowsAndCategories(true);
138+
139+
loadCategories();
147140
}
148141

149142
protected void loadCategories() {

src/main/java/gwt/material/design/demo/client/application/datatable/paged/PagedDataTableView.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,7 @@ interface Binder extends UiBinder<Widget, PagedDataTableView> {
6666
@Inject
6767
PagedDataTableView(Binder uiBinder) {
6868
initWidget(uiBinder.createAndBindUi(this));
69-
}
70-
71-
@Override
72-
protected void onAttach() {
73-
super.onAttach();
74-
75-
loadDataTable();
76-
}
7769

78-
protected void loadDataTable() {
7970
// Generate 20 categories
8071
int rowIndex = 1;
8172
List<Person> people = new ArrayList<>();

src/main/java/gwt/material/design/demo/client/application/datatable/standard/StandardDataTableView.java

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,7 @@ protected void render(TableSubHeader subheader) {
8383
@Inject
8484
StandardDataTableView(Binder uiBinder) {
8585
initWidget(uiBinder.createAndBindUi(this));
86-
}
87-
88-
@Override
89-
protected void onAttach() {
90-
super.onAttach();
91-
92-
loadDataTable();
93-
}
9486

95-
protected void loadDataTable() {
9687
generatePeople();
9788

9889
// Populate the ComboBox value
@@ -114,9 +105,7 @@ protected void loadDataTable() {
114105
// We will define our own person row factory to generate the
115106
// category name. This can be used to generate your own
116107
// RowComponent's too, if custom functionality is required.
117-
table.setRowFactory(new
118-
119-
PersonRowFactory());
108+
table.setRowFactory(new PersonRowFactory());
120109

121110
// If we want to generate all our categories using CustomCategoryComponent
122111
// We can define our own CategoryComponentFactory. There we can define our
@@ -128,9 +117,7 @@ protected void loadDataTable() {
128117
// methods to create elements the way you would like.
129118
table.setRenderer(new CustomRenderer<>());
130119

131-
table.addColumn(new WidgetColumn<Person, MaterialImage>()
132-
133-
{
120+
table.addColumn(new WidgetColumn<Person, MaterialImage>() {
134121
@Override
135122
public MaterialImage getValue(Person object) {
136123
MaterialImage profile = new MaterialImage();
@@ -147,9 +134,7 @@ public MaterialImage getValue(Person object) {
147134

148135
// Now we will add our tables columns.
149136
// There are a number of methods that can provide custom column configurations.
150-
table.addColumn(new TextColumn<Person>()
151-
152-
{
137+
table.addColumn(new TextColumn<Person>() {
153138
@Override
154139
public Comparator<? super RowComponent<Person>> sortComparator() {
155140
return (o1, o2) -> o1.getData().getFirstName().compareToIgnoreCase(o2.getData().getFirstName());
@@ -161,9 +146,7 @@ public String getValue(Person object) {
161146
}
162147
}, "First Name");
163148

164-
table.addColumn(new TextColumn<Person>()
165-
166-
{
149+
table.addColumn(new TextColumn<Person>() {
167150
@Override
168151
public Comparator<? super RowComponent<Person>> sortComparator() {
169152
return (o1, o2) -> o1.getData().getLastName().compareToIgnoreCase(o2.getData().getLastName());
@@ -175,9 +158,7 @@ public String getValue(Person object) {
175158
}
176159
}, "Last Name");
177160

178-
table.addColumn(new TextColumn<Person>()
179-
180-
{
161+
table.addColumn(new TextColumn<Person>() {
181162
@Override
182163
public Comparator<? super RowComponent<Person>> sortComparator() {
183164
return (o1, o2) -> o1.getData().getEmail().compareToIgnoreCase(o2.getData().getEmail());
@@ -189,9 +170,7 @@ public String getValue(Person object) {
189170
}
190171
}, "Email");
191172

192-
table.addColumn(new TextColumn<Person>()
193-
194-
{
173+
table.addColumn(new TextColumn<Person>() {
195174
@Override
196175
public boolean numeric() {
197176
return true;
@@ -213,10 +192,7 @@ public String getValue(Person object) {
213192
}
214193
}, "Phone");
215194

216-
table.addColumn(new WidgetColumn<Person, MaterialComboBox>()
217-
218-
{
219-
195+
table.addColumn(new WidgetColumn<Person, MaterialComboBox>() {
220196
@Override
221197
public MaterialComboBox getValue(Person object) {
222198
MaterialComboBox<String> comboBox = new MaterialComboBox<>();
@@ -231,9 +207,7 @@ public MaterialComboBox getValue(Person object) {
231207

232208
// Example of a widget column!
233209
// You can add any handler to the column cells widget.
234-
table.addColumn(new WidgetColumn<Person, MaterialBadge>()
235-
236-
{
210+
table.addColumn(new WidgetColumn<Person, MaterialBadge>() {
237211
@Override
238212
public TextAlign textAlign() {
239213
return TextAlign.CENTER;

0 commit comments

Comments
 (0)