Announcement

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

    ListGrid: problem adding embedded component

    Using SmartClient Version: v9.0p_2013-07-10/Enterprise Deployment (built 2013-07-10) with IE9.

    Added new records with embedded components to a List Grid causes existing embedded components to disappear from the existing records.

    I have included code below that works in v8.3p_2013-04-13/Enterprise Deployment (2013-04-13) but exhibits the problem when in used in the 4.0p-2013-07-10 code base.

    Add record...update name...select new record...click Add Embedded...Add another record the same way and the first embeded component is removed from the screen.

    Code:
    	@Override
    	public void onModuleLoad()
    	{
    		final ListGrid grid = new ListGrid();
    		VLayout groupingLayout = new VLayout();
    		groupingLayout.setSize("100%", "100%");
    
    		ToolStrip strip = new ToolStrip();
    
    		ToolStripButton button = new ToolStripButton("Add");
    		button.addClickHandler(new ClickHandler()
    		{
    
    			@Override
    			public void onClick(ClickEvent event)
    			{
    				grid.startEditingNew();
    			}
    		});
    		strip.addButton(button);
    
    		button = new ToolStripButton("Add Embedded");
    		button.addClickHandler(new ClickHandler()
    		{
    
    			@Override
    			public void onClick(ClickEvent event)
    			{
    				if ( grid.getSelectedRecord() != null)
    				{
    				grid.addEmbeddedComponent(new ListGrid(), grid.getSelectedRecord());
    				}
    				else
    				{
    					SC.say("Select record to add embedded component");
    				}
    			}
    		});
    
    		strip.addButton(button);
    		groupingLayout.addMember(strip);
    
    		grid.setSize("100%", "*");
    
    		ListGridField name = new ListGridField("name");
    		grid.setFields(name);
    
    		groupingLayout.addMember(grid);
    
    		groupingLayout.draw();
    	}

    #2
    There's an entire existing subsytem for doing what your trying to do here - have you seen the docs for ListGrid.showRecordComponents?

    If you want to assign components to records and have them behave properly with cache sync, et al, then you should use that subsystem.

    If you really need to add components manually in this fashion, you can set ListGrid.recordComponentPoolingMode to "data" - this will prevent component-remapping on dataChanged() from removing your components.

    Comment

    Working...
    X