Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    4.0d (pro): ListGrid.removeData(Object data) stopped working

    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:

    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);
    	}
    }
    No entries are removed when using the context menu - debugging shows that the record is actually there just before the call to removeData().

    #2
    Thanks for the report - you should find this fixed from tomorrow's 4.0 nightly build, dated May 29, and onwards. Note that the signature for removeData() has changed from (Object data) to (Record data)

    Comment


      #3
      Thank you - I've had to rely on selecting rows and using removeSelectedData() in the meantime :-/

      Hopefully the performance of ListGrid's in general will also get back to the level of 3.1 ;)

      Comment

      Working...
      X