Is there any possible way to align a DynamicForm horizontally to the center of a VLayout? I've tried what is done in this showcase demo, but it won't work for the form (it does work correctly for the IButton).
Here is my
Here is my
Code:
package co.focuss.bmsimulator.client.ui.widgets;
import com.google.gwt.core.client.GWT;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.TitleOrientation;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.layout.SectionStackSection;
import co.focuss.bmsimulator.client.internationalization.BMSimulatorConstants;
public class PreferencesStackSection extends SectionStackSection {
private static final String SAVE_ICON = "icons/save.png";
private static final int COMPONENT_GAP = 10;
// Object used to get access to internationalization constants and messages
private BMSimulatorConstants constants = GWT.create(BMSimulatorConstants.class);
private DataSource ds;
private DynamicForm form;
private IButton saveBtn;
public PreferencesStackSection(String title) {
super(title);
ds = DataSource.get("preferences");
buildPreferencesLayout();
}
private void buildPreferencesLayout() {
VLayout layout = new VLayout(COMPONENT_GAP);
layout.setMargin(COMPONENT_GAP * 2);
layout.setDefaultLayoutAlign(Alignment.CENTER);
createPreferencesForm(layout);
createSaveButton(layout);
this.addItem(layout);
}
private void createPreferencesForm(VLayout layout) {
form = new DynamicForm();
form.setNumCols(1);
form.setTitleOrientation(TitleOrientation.TOP);
form.setDataSource(ds);
layout.addMember(form);
}
private void createSaveButton(VLayout layout) {
saveBtn = new IButton(constants.preferencesSaveButton());
saveBtn.setIcon(SAVE_ICON);
saveBtn.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
DSCallback callback = new DSCallback() {
public void execute(DSResponse response, Object rawData, DSRequest request){
SC.say(constants.preferencesSavedOK());
}
};
form.saveData(callback);
}
});
layout.addMember(saveBtn);
}
}
Comment