SmartGWT 3.0 Power NB from Aug 28
The ListGrid on my app's initial page consistently renders the last row (sometimes two) with missing components. I've overridden createRecordComponent() in order to create control buttons based on the record state, and it's those buttons that are not rendered in the initial draw; any subsequent navigation to the page is fine, all buttons show up. I also have a refresh button that fixes it but I really need the display to be complete on startup.
Any help greatly appreciated!
The ListGrid on my app's initial page consistently renders the last row (sometimes two) with missing components. I've overridden createRecordComponent() in order to create control buttons based on the record state, and it's those buttons that are not rendered in the initial draw; any subsequent navigation to the page is fine, all buttons show up. I also have a refresh button that fixes it but I really need the display to be complete on startup.
Code:
public class SummaryTable extends ListGrid { /** * Constructor. */ public SummaryTable(DataSource aDatasource, final RPCCallback anRPCCallback, NotificationBar aNotificationBar) { super(); theRPCCallback = anRPCCallback; theNotificationBar = aNotificationBar; setDataSource(aDatasource); // not all fields are displayed in the table setUseAllDataSourceFields(false); setAutoFetchData(true); setCellPadding(CELL_PADDING); // render each cell individually in order to format setShowRecordComponents(true); setShowRecordComponentsByCell(true); setCanEdit(false); ListGridField statusField = new ListGridField(STATUS_FIELD); statusField.setShowValueIconOnly(true); // get a map of all ElementServiceState status codes-to-icons that can be passed into // the ListGridField.setValueIcons() method, a SmartGWT convenience method Map<String, String> stateToIconMap = ElementServiceState.getStateToIconMap(); statusField.setValueIcons(stateToIconMap); statusField.setValueIconSize(BUTTON_HEIGHT); ListGridField nameField = new ListGridField(ELEMENT_SERVICE_FIELD, ELEMENT_SERVICE_DISPLAY_NAME); ListGridField commandField = new ListGridField(COMMAND, COMMAND_DISPLAY_NAME); commandField.setAlign(Alignment.CENTER); setFields(statusField, nameField, commandField); } /** * This method is overridden in order to format the timestamp from the database and also to create command buttons * that depend on the status code of the associated record (an ElementService). */ @Override protected Canvas createRecordComponent(final ListGridRecord aRecord, final Integer aColumnNumber) { // returning null will result in all table cells using default Canvas supplied by the framework // only the canvases for the Command cells will be supplied in this method Canvas recordCanvas = null; String fieldName = getFieldName(aColumnNumber); final String elementService = aRecord.getAttribute(FUNCTION); // the status of this record final ElementServiceState status = ElementServiceState.getStatus(aRecord.getAttribute(STATUS_FIELD)); // the timestamp value read from the database must be formatted into GOES-R date display if (fieldName.equals(LAST_REPORTED_TIME_FIELD)) { String displayedDate = ServiceManagementInterface.formatTimestamp(aRecord.getAttribute(LAST_REPORTED_TIME_FIELD)); aRecord.setAttribute(LAST_REPORTED_TIME_FIELD, displayedDate); } else if (fieldName.equals(COMMAND)) { final ResourceManagerCommand command = status.getCommand(); // add a command button if this element service has a valid command if (command != ResourceManagerCommand.NONE) { // create the buttons used to start and stop element services recordCanvas = new HLayout(); recordCanvas.setHeight(BUTTON_HEIGHT); recordCanvas.setAlign(Alignment.CENTER); IButton commandBtn = ServiceManagementInterface.makeIconButton(command.getIcon()); String blank = " "; commandBtn.setPrompt(command.getAction() + blank + elementService); // command button uses an anonymous inner click handler class commandBtn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent anEvent) { if (command.equals(ResourceManagerCommand.START_ES)) { ConfirmCommand dialog = new ConfirmCommand(ResourceManagerCommand.START_ES, elementService, theRPCCallback, theNotificationBar); dialog.show(); } else if (command.equals(ResourceManagerCommand.STOP_ES)) { // if the command is not ResourceManagerCommand.START_ES, // then ResourceManagerCommand.STOP_ES is deduced ConfirmCommand dialog = new ConfirmCommand(ResourceManagerCommand.STOP_ES, elementService, theRPCCallback, theNotificationBar); dialog.show(); } else { SC.warn("Invalid command for " + elementService); } } });// end ClickHandler ((Layout) recordCanvas).addMember(commandBtn); } } return recordCanvas; } }
Comment