Following an upgrade from smartGWT pro 3.1 to pro 4.0 it seems that ListGrid.removeData(Object data) no longer removes the desires entry in the ListGrid!!
With nightly build of 30/4 the following code should illustrate the problem:
No entries are removed when using the context menu - debugging shows that the record is actually there just before the call to removeData().
With nightly build of 30/4 the following code should illustrate the problem:
Code:
public class SmartGWTProTestCanvas implements EntryPoint { ListGrid usersGrid; public void onModuleLoad() { VLayout layout = new VLayout(); layout.setMembersMargin(10); final HLayout parentCanvas = new HLayout(); parentCanvas.setTop(40); parentCanvas.setWidth(600); parentCanvas.setHeight(500); parentCanvas.setShowEdges(true); usersGrid = new ListGrid(); usersGrid.setHeight100(); usersGrid.setWidth100(); usersGrid.setAlternateRecordStyles(true); usersGrid.setShowAllRecords(true); usersGrid.setIsGroup(false); usersGrid.setCanGroupBy(false); ListGridField userIdField = new ListGridField("id", "Id"); ListGridField usernameField = new ListGridField("name", "Name"); ListGridField adminField = new ListGridField("isAdmin", "Administrator"); adminField.setType(ListGridFieldType.BOOLEAN); usersGrid.setFields(new ListGridField[] { userIdField, usernameField, adminField }); Menu usersGridContextMenu = new Menu(); usersGridContextMenu.setWidth(150); MenuItem removeUserContextMenuItem = new MenuItem(); removeUserContextMenuItem.setTitle("Remove Record"); removeUserContextMenuItem.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() { public void onClick(MenuItemClickEvent event) { ListGridRecord userRecord = usersGrid.getSelectedRecord(); usersGrid.removeData(userRecord); } }); usersGridContextMenu.setItems(removeUserContextMenuItem); usersGrid.setContextMenu(usersGridContextMenu); parentCanvas.addMember(usersGrid); layout.addMember(parentCanvas); layout.draw(); RootPanel.get("testContainer").add(layout); addUsers(); } private void addUsers() { ListGridRecord[] data = new ListGridRecord[10]; for (int i = 0; i < 10; i++) { ListGridRecord record = new ListGridRecord(); record.setAttribute("id", i); record.setAttribute("name", "User_" + i); record.setAttribute("isAdmin", Random.nextBoolean()); data[i] = record; } usersGrid.setData(data); } }
Comment