GwtMaterialDesign / gwt-material-table

A complex table component designed for the material design specifications
https://gwtmaterialdesign.github.io/gmd-table-demo/
Apache License 2.0
27 stars 31 forks source link

AbstractDataTable.removeColumns() throws IndexOutOfBoundsException if the table has columns. #126

Open EdgarKogel opened 6 years ago

EdgarKogel commented 6 years ago

Hi! It seems that the method AbstractDataView.removeColums() has a problem.

The loop inside the method operates on a changing array which causes an IndexOutOfBoundsException.

The current version looks like this:

int size = columns.size() - 1;
for (int i = 0; i < size; i++) {
   removeColumn(i, false);
}

In my opinion it should be:

int size = columns.size();
for (int i = 0; i < size; i++) {
   removeColumn(0, false);
}

Currently I use as workaround an external method direct on the table which looks like this:

final int columnSize = table.getColumns().size();
for (int i = 0; i < columnSize; i++) {
    table.removeColumn(0);
}

Would be fine if this can be fixed in the code.

Kind regards

BenDol commented 6 years ago

Sorry for the late response, will take a look at this soon. Thanks for taking the time to submit this issue.

lukas0krupa commented 4 years ago

Not sure it this helps, but I encounter similar problem. Workaround works for now.

EDIT: Not even workaround works now.

Console output:

Throwable.java:116 Uncaught Error: java.lang.IndexOutOfBoundsException
    at IndexOutOfBoundsException_1_g$.createError_0_g$ [as createError_2_g$] (Throwable.java:116:1)
    at IndexOutOfBoundsException_1_g$.initializeBackingError_0_g$ [as initializeBackingError_1_g$] Throwable.java:108:1)
    at IndexOutOfBoundsException_1_g$.Throwable_1_g$ (Throwable.java:62:1)
    at IndexOutOfBoundsException_1_g$.Exception_1_g$ (Exception.java:25:1)
    at IndexOutOfBoundsException_1_g$.RuntimeException_1_g$ (RuntimeException.java:25:1)
    at new IndexOutOfBoundsException_1_g$ (IndexOutOfBoundsException.java:25:1)
    at WidgetCollection_1_g$.get_270_g$ [as get_562_g$] (WidgetCollection.java:112:1)
    at TableRow_1_g$.getWidget_0_g$ [as getWidget_10_g$] (ComplexPanel.java:36:1)
    at TableRow_1_g$.remove_6_g$ [as remove_244_g$] (ComplexPanel.java:56:1)
    at StandardDataView_1_g$.removeColumn_2_g$ [as removeColumn_4_g$] (AbstractDataView.java:1331:1)
    at StandardDataView_1_g$.removeColumns_1_g$ [as removeColumns_2_g$] (AbstractDataView.java:1350:1)
    at CustomDataTable_1_g$.removeColumns_0_g$ [as removeColumns_2_g$] (AbstractDataTable.java:342:1)

Table has the following columns (ordered as added): TextColumn, WidgetColumn, IntegerColumn, WidgetColumn (4x).