Announcement

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

    ListGrid in Window doesn't show up until I "nudge" the window

    I still seem to be struggling with basic UI component drawing behavior. I'm creating a Window and using addItem() to add a VLayout to the window. I'm calling setMembers() to add three Canvases to the layout, an HTMLPane, an HLayout with a few IButtons in it and a ListGrid. I then call setData() on the ListGrid and call show() on the Window.

    Everything appears in the Window except the ListGrid. If I drag resize the Window just slightly the ListGrid appears and afterward everything works fine. What am I missing?

    Here is the class that creates and shows the window.
    Code:
    package com.islandpacific.gui.client;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.DataSourceField;
    import com.smartgwt.client.data.RecordList;
    import com.smartgwt.client.types.Overflow;
    import com.smartgwt.client.types.SelectionAppearance;
    import com.smartgwt.client.types.SelectionStyle;
    import com.smartgwt.client.widgets.HTMLPane;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.events.CloseClickHandler;
    import com.smartgwt.client.widgets.events.CloseClientEvent;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class CommonPrepack {
    
    	private static IpListGrid grid = null;
    	private static Window window = null;
    
    	/**
    	 * Displays a prepack definition from the common SKU database and lets
    	 * the user confirm the details. They also have the option of changing
    	 * the default value for selected fields. If they continue, any items
    	 * not already defined in this database will be defined in the item master
    	 * and the default prepack contents will be returned to the PoItemEditor
    	 * so it can continue letting the user define the prepack.
    	 * 
    	 * @param message A message to display above the prepack contents grid.
    	 * @param csComponents The common SKU component items with default values.
    	 * @param callback A callback to inform when the user continues or cancels.
    	 */
    	public static void confirm(String message, RecordList csComponents,
    			final IpBooleanCallback callback) {
    
    		if (window==null) {
    			window = new Window();
    			window.setTitle("Confirm Creation of Common Prepack");
    			window.setIsModal(true);
    			window.setShowModalMask(true);
    			window.setAutoSize(true);
    			window.setAutoCenter(true);
    			window.setKeepInParentRect(true);
    			window.setPadding(5);
    			window.setCanDragResize(true);
    			window.setShowCloseButton(false);
    			window.setShowMinimizeButton(false);
    			window.setShowMaximizeButton(true);
    			window.setShowHeaderIcon(true);
    			window.setHeaderIcon("customimages/prepack-icon.png", 16, 16);
    			window.setHeight(500);
    			window.setWidth(600);
    			window.addCloseClickHandler(new CloseClickHandler() {		
    				@Override
    				public void onCloseClick(CloseClientEvent event) {
    					window.hide();
    					window.destroy();
    					callback.onFalse();
    				}
    			});
    
    
    			HTMLPane msgPane = new HTMLPane();
    			msgPane.setContents(message +
    					"<p>Confirm the pack details below and press OK to continue.");
    			msgPane.setWidth100();
    			msgPane.setHeight(100);	
    			msgPane.setOverflow(Overflow.VISIBLE);
    			IButton okButton = new IButton("OK");
    			okButton.addClickHandler(new ClickHandler() {
    
    				@Override
    				public void onClick(ClickEvent event) {
    					// Define all undefined items in the item master file first
    					// and then return a list of PoPackContents records.
    					callback.onTrue();
    				}
    			});
    			IButton cancelButton = new IButton("Cancel");
    			cancelButton.addClickHandler(new ClickHandler() {
    
    				@Override
    				public void onClick(ClickEvent event) {
    					window.hide();
    					window.destroy();
    					callback.onFalse();
    				}
    			});
    			IButton editButton = new IButton("Edit Selected Items");
    			editButton.addClickHandler(new ClickHandler() {
    
    				@Override
    				public void onClick(ClickEvent event) {
    					grid.editSelectedRecords();
    				}
    			});
    			editButton.setAutoFit(true);
    			HLayout buttonLayout = new HLayout(10);
    			buttonLayout.setMembers(okButton, cancelButton, editButton);
    			buttonLayout.setAutoHeight();
    			buttonLayout.setWidth100();		
    			VLayout layout = new VLayout(10);
    			layout.setHeight100();
    			layout.setWidth100();
    			layout.setMargin(10);
    			layout.setMembers(msgPane, buttonLayout, getGrid());
    			window.addItem(layout);
    		}
    		getGrid().setData(csComponents);
    		window.show();
    	}
    
    	private static IpListGrid getGrid() {
    
    		if (grid==null) {
    			grid = new IpListGrid("CommonPrepack.grid") {
    				@Override
    				protected boolean canEditCell(int rowNum, int colNum) {
    
    					// Get the grid record and column name.
    					ListGridRecord rec = getRecord(rowNum);
    					String colName = getFieldName(colNum);
    
    					// If the SKU already exists in this database, the row cannot be edited.
    					String csNewSKU = rec.getAttribute("csNewSKU");
    					if ("N".equals(csNewSKU))
    						return false;
    
    					// Otherwise, only selected fields can be edited.
    					else if ("IDES".equals(colName) 
    							|| "ISDS".equals(colName)
    							|| "IVST".equals(colName)
    							|| "IVNC".equals(colName)
    							|| "IRET".equals(colName)
    							|| colName.startsWith("IATT"))
    						return true;
    					else
    						return false;
    				}
    			};
    
    			// Set the data source and other grid attributes.
    			DataSource commonSKUDefaultsDS = DataSource.get(IslandPacificDSConstants.DATASOURCE_CommonSKUDefaults);
    			grid.setDataSource(commonSKUDefaultsDS);
    			grid.setWidth100();
    			grid.setHeight100();
    
    			// Let the user select multiple records to update them as a group
    			grid.setSelectionAppearance(SelectionAppearance.CHECKBOX);
    			grid.setSelectionType(SelectionStyle.MULTIPLE);
    
    			// Set the list of fields.
    			List fields = new ArrayList<ListGridField>();
    			fields.add(new ListGridField("ItemNumber"));
    			fields.add(new ListGridField("COMPQTY"));
    			fields.add(new ListGridField("IDES"));
    			fields.add(new ListGridField("ISDS"));
    			fields.add(new ListGridField("IVST"));
    			fields.add(new ListGridField("IVNC"));
    			fields.add(new ListGridField("IRET"));
    
    			// Add any required item attributes.
    			for (DataSourceField dsField : commonSKUDefaultsDS.getFields()) {
    				if (dsField.getName().startsWith("IATT") && dsField.getRequired())
    					fields.add(new ListGridField(dsField.getName()));
    			}
    			ListGridField[] fieldsArray = new ListGridField[fields.size()];
    			grid.setFields((ListGridField[]) fields.toArray(fieldsArray));
    
    			// Restore the user's grid settings.
    			grid.loadGridSettingsForCurrentUser();
    		}
    		return grid;
    	}
    }

    #2
    Use the Watch tab. The ListGrid is probably there as a 1px tall line, because it's being squished down to that size by other components that need space.

    Comment


      #3
      Hi Isomorphic,
      Im also facing same issue. Please find the attached screenshots with WatchTab elements.

      In the screenshots, i've used colored backgrounds to identify the window,VLayout and Listgrid.

      This is what im doing:

      Im attaching a panel to the window first. after submitting that panel, im removing that panel and attaching another panel,which is giving problem now. You can find the same in screenshots. When i am just resizing the window, it is showing listgrid correctly. I couldnt find the solution for this. Ofcourse i couldnt find the actual root cause that is causing this.

      How to resolve this?
      Attached Files

      Comment

      Working...
      X