When calling setFields a second time on a listgrid but with one field less (to remove a field) a javascriptexception is thrown. This only happens when you remove a field that is not the last one.
Tested this with SmartClient Version: SC_SNAPSHOT-2011-05-14/PowerEdition Deployment (built 2011-05-14) in gwt 2.1.0 on Firefox 4.
The exception
Tested this with SmartClient Version: SC_SNAPSHOT-2011-05-14/PowerEdition Deployment (built 2011-05-14) in gwt 2.1.0 on Firefox 4.
Code:
package test.client;
import java.util.ArrayList;
import java.util.List;
import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.widgets.Button;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.layout.VLayout;
public class RemoveField implements EntryPoint {
private List<ListGridField> listGridFields;
private ListGrid listGrid;
public void onModuleLoad() {
DataSource ds = DataSource.get("contents");
listGridFields = new ArrayList<ListGridField>();
for (DataSourceField field: ds.getFields()) {
ListGridField listGridField = new ListGridField(field.getName(), field.getName() + "_Title");
listGridFields.add(listGridField);
}
listGrid = new ListGrid();
listGrid.setDataSource(ds);
listGrid.setFields(listGridFields.toArray(new ListGridField[0]));
listGrid.setShowFilterEditor(true);
listGrid.setShowHeader(true);
Button button = new Button();
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
listGridFields.remove(0);
listGrid.setFields(listGridFields.toArray(new ListGridField[0]));
}
});
VLayout vLayout = new VLayout();
vLayout.addMember(listGrid);
vLayout.addMember(button);
vLayout.setWidth100();
vLayout.setHeight100();
vLayout.draw();
}
}
Code:
Uncaught exception escaped : com.google.gwt.core.client.JavaScriptException
(TypeError): _1 is null
fileName: http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Grids.js
lineNumber: 1118
stack: isc_ListGrid__canSort(null)@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Grids.js:1118
()@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Grids.js:979
isc_Canvas_getTagStart(true)@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:2223
isc_Canvas__insertHTML(true)@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:2130
isc_Canvas_draw((void 0),(void 0),(void 0))@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:2060
isc_StatefulCanvas_draw()@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Foundation.js:286
isc_Layout_layoutChildren("initial draw")@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Foundation.js:462
isc_Layout_drawChildren()@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Foundation.js:361
isc_Canvas_draw((void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0))@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:2060
isc_c_Class_invokeSuper([object Object],"draw",(void 0),(void 0),(void 0),(void 0))@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:305
isc_Toolbar_draw()@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Foundation.js:764
isc_c_Class_invokeSuper(null,"draw")@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:305
isc_c_Class_Super("draw",[object Arguments])@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:297
()@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Grids.js:2599
isc_ListGrid__updateFieldWidths("set fields",(void 0),(void 0))@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Grids.js:1378
isc_ListGrid_layoutChildren("set fields")@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Grids.js:1373
isc_ListGrid_setFields([object Array])@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Grids.js:1283
isc_Class_setProperties([object Object])@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:388
isc_Class_setProperty("fields",[object Array])@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:386
("fields",[object Array])@http://127.0.0.1:8888:171
([object GWTJavaObject],1179847,[object GWTJavaObject])@http://127.0.0.1:8888/smartgwt2/hosted.html?smartgwt2:56
([object Object],(void 0))@http://127.0.0.1:8888:118
((function () {var param = {};var event = __gwt_makeJavaInvoke(1)(null, 1507447, param);__gwt_makeJavaInvoke(1)(selfJ, 1179847, event);var ret = __gwt_makeJavaInvoke(0)(event, 1376262);return !ret;}),[object Object],[object Arguments])@http://127.0.0.1:8888:31
(null,65642,(function () {var param = {};var event = __gwt_makeJavaInvoke(1)(null, 1507447, param);__gwt_makeJavaInvoke(1)(selfJ, 1179847, event);var ret = __gwt_makeJavaInvoke(0)(event, 1376262);return !ret;}),[object Object],[object Arguments])@http://127.0.0.1:8888/smartgwt2/hosted.html?smartgwt2:56
([object Object],(void 0))@http://127.0.0.1:8888:15
([object Object],(void 0))@http://127.0.0.1:8888:13
isc_StatefulCanvas_handleActivate([object Object],(void 0))@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Foundation.js:319
isc_StatefulCanvas_handleClick([object Object],(void 0))@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Foundation.js:321
isc_c_EventHandler_bubbleEvent([object Object],"click")@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:1597
isc_c_EventHandler_handleClick([object Object])@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:1445
isc_c_EventHandler__handleMouseUp([object MouseEvent],(void 0))@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:1432
isc_c_EventHandler_handleMouseUp([object MouseEvent])@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:1423
isc_c_EventHandler_dispatch(isc_c_EventHandler_handleMouseUp,[object MouseEvent])@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:1660
anonymous([object MouseEvent])@http://127.0.0.1:8888/smartgwt2/sc/modules/ISC_Core.js:61
See the Development console log for details.
Register a GWT.setUncaughtExceptionHandler(..) for custom uncaught exception handling.
Comment