gwt-material-table icon indicating copy to clipboard operation
gwt-material-table copied to clipboard

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

Open EdgarKogel opened this issue 7 years ago • 2 comments

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

EdgarKogel avatar Dec 15 '17 19:12 EdgarKogel

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

BenDol avatar Jan 31 '18 09:01 BenDol

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).

lukas0krupa avatar Jul 07 '20 14:07 lukas0krupa