I really need some help if I'm to get this working...
I have a layout with some datechooser and labels. It all works fine in desktop, But if I set it to handset mode, the datechoosers are not visible.
I've looked around, but can't get it to work. It's very strange to me. If someone could check my test case below, I'd be most grateful!
I have a layout with some datechooser and labels. It all works fine in desktop, But if I set it to handset mode, the datechoosers are not visible.
I've looked around, but can't get it to work. It's very strange to me. If someone could check my test case below, I'd be most grateful!
Code:
package com.nuba.client; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.AnimationEffect; import com.smartgwt.client.types.VerticalAlignment; import com.smartgwt.client.util.Browser; import com.smartgwt.client.widgets.DateChooser; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.Layout; import com.smartgwt.client.widgets.layout.VLayout; public class TestDateControls { public static int spacing = Browser.getIsHandset() ? 10 : 20; public void onModuleLoad() { //Browser.setIsHandset(true); IButton action = new IButton("Hello"); IButton cancel = new IButton("Goodbye"); DateRangeChooserFilterLayout layout = new DateRangeChooserFilterLayout(action, cancel); Layout main = (Layout) new HLayout().setWidth100().setHeight100(); main.addMember(layout); main.draw(); } private class DateRangeChooserFilterLayout extends VLayout { public DateRangeChooserFilterLayout(IButton actionButton, IButton cancelButton) { setAnimateShowEffect(AnimationEffect.FADE).setAnimateFadeTime(500); setAutoWidth(); setAutoHeight(); setMembersMargin(WebConstants.getLargeSpacing()); DefaultLabel headerLabel = new DefaultLabel("Select Period", null, Alignment.LEFT); headerLabel.setPadding(15); headerLabel.setWidth100(); headerLabel.setAlign(Alignment.CENTER); headerLabel.setMinWidth(250); headerLabel.setLayoutAlign(Alignment.CENTER); addMember(headerLabel); Layout dateChooserComponentsLayout = new HLayout(); DefaultLabel endText = new DefaultLabel("To: ", null, Alignment.LEFT); endText.setAutoWidth(); DateChooser beginChooser = new DateChooser(); DateChooser endChooser = new DateChooser(); dateChooserComponentsLayout.addMember(beginChooser); dateChooserComponentsLayout.addMember(endText); dateChooserComponentsLayout.addMember(endChooser); dateChooserComponentsLayout.setAutoWidth(); addMember(dateChooserComponentsLayout); Layout buttonLayout = new DefaultHLayout(); buttonLayout.setAutoHeight(); buttonLayout.setMembersMargin(spacing); buttonLayout.setLayoutAlign(Alignment.CENTER); buttonLayout.setAutoWidth(); if (actionButton != null) { buttonLayout.addMembers(actionButton, cancelButton); } addMember(buttonLayout); } } public class DefaultLabel extends Label { public DefaultLabel(String text, String styleName) { super(text); setAutoHeight(); setCanFocus(false); if (styleName != null) { setStyleName(styleName); } } public DefaultLabel(String text, String styleName, Alignment align) { this(text, styleName); setAlign(align); } public DefaultLabel(String text, String styleName, Alignment textAlign, int width) { this(text, styleName, textAlign); setWidth(width); } } public class DefaultVLayout extends VLayout { public DefaultVLayout() { setAutoHeight(); setWidth100(); setMembersMargin(spacing); setDefaultLayoutAlign(Alignment.LEFT); setAlign(Alignment.LEFT); setAlign(VerticalAlignment.TOP); setLayoutAlign(Alignment.LEFT); } } public class DefaultHLayout extends HLayout { public DefaultHLayout() { this(null); } public DefaultHLayout(String groupName) { super(); setAlign(Alignment.LEFT); setDefaultLayoutAlign(VerticalAlignment.CENTER); setAutoHeight(); setAutoWidth(); setMembersMargin(spacing); if (groupName != null) { setIsGroup(true); setGroupTitle(groupName); setPadding(spacing); //smartgwt doesn't support to set a style for the border, so we have to hard-code it here setGroupBorderCSS(WebConstants.DEFAULT_BORDER); } } } }
Comment