我使用Window
和setIsModal(true)
时遇到一个问题。
我有这段代码:
@Override
public void onModuleLoad() {
Button tester = new Button("Tester");
tester.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final com.smartgwt.client.widgets.Window win = new com.smartgwt.client.widgets.Window();
win.setTitle("Ventana Tester");
win.setWidth(900);
win.setHeight(600);
win.setIsModal(true);
win.setShowModalMask(true);
win.centerInPage();
win.setMinimized(false);
win.addCloseClickHandler(new CloseClickHandler() {
@Override
public void onCloseClick(CloseClientEvent event) {
win.destroy();
}
});
PlanBoard pb = new PlanBoard();
win.addItem(pb);
win.show();
}
});
vlPrincipal.addMember(tester);
RootPanel.get("main").add(vlPrincipal);
}
这是PlanBoard类:
public class PlanBoard extends VLayout{
private CaptionPanel contentDetallePlan = new CaptionPanel("DETALLES DEL PLAN");
private CaptionPanel contentAtributosPlan = new CaptionPanel("ATRIBUTOS DE PLAN");
private CaptionPanel contentSeccionesPlan = new CaptionPanel("SECCIONES");
public PlanBoard(){
contentDetallePlan.setStyleName("estiloCaptionPanel");
contentAtributosPlan.setStyleName("estiloCaptionPanel");
addMember(contentDetallePlan);
addMember(contentAtributosPlan);
addMember(contentSeccionesPlan);
preparaDetallePlan();
preparaAtributosPlan();
}
private void preparaDetallePlan(){
VLayout contenedorSeccion = new VLayout();
FlexTable table1 = new FlexTable();
FlexTable table2 = new FlexTable();
FlexTable table3 = new FlexTable();
Label np = new Label("Nombre de Plan:");
Label npText = new Label("Plan B");
Label tc = new Label("Tipo de Carta:");
DynamicForm tcForm = new DynamicForm();
ComboBoxItem tcBox = new ComboBoxItem();
tcBox.setWidth(250);
tcBox.setShowTitle(false);
tcForm.setItems(tcBox);
Label pr = new Label("Periodo:");
DynamicForm prForm = new DynamicForm();
ComboBoxItem prBox = new ComboBoxItem();
prBox.setWidth(150);
prBox.setShowTitle(false);
prForm.setItems(prBox);
Label dp = new Label("Descripcion:");
DynamicForm dpForm = new DynamicForm();
TextAreaItem dpText = new TextAreaItem();
dpText.setShowTitle(false);
dpText.setWidth(600);
dpForm.setItems(dpText);
table1.setWidget(0, 0, np);
table1.setWidget(0, 1, npText);
table2.setWidget(0, 0, tc);
table2.setWidget(0, 1, tcForm);
table2.setWidget(0, 2, pr);
table2.setWidget(0, 3, prForm);
table3.setWidget(0, 1, dp);
table3.setWidget(1, 1, dpForm);
contenedorSeccion.addMember(table1);
contenedorSeccion.addMember(table2);
contenedorSeccion.addMember(table3);
contentDetallePlan.add(contenedorSeccion);
}
private void preparaAtributosPlan(){
VLayout contenedorSeccion = new VLayout();
FlexTable table1 = new FlexTable();
Label fe = new Label("Firma Electornica:");
CheckboxItem feCheck = new CheckboxItem();
DateItem feFechaIni = new DateItem();
DateItem feFechaFin = new DateItem();
feFechaIni.setUseTextField(true);
feCheck.setShowTitle(false);
DynamicForm feForm = new DynamicForm();
feForm.setItems(feCheck,feFechaIni,feFechaFin);
table1.setWidget(0, 0, fe);
table1.setWidget(0, 1, feForm);
contenedorSeccion.addMember(table1);
contentAtributosPlan.add(contenedorSeccion);
}
问题是,当我尝试点击CheckBoxItem
或DateItem
时,我无法对其进行编辑,但是当我不使用setIsModal(true)
时,它可以正常工作细
我不知道如何将Window
设置为modal(true)
,并让这些项目在该窗口上运行。
答案 0 :(得分:1)
这是你的代码清理(一点点)和改进,以便你想要实现的目标(这是具有可选/可操作控件的模态窗口):
<强> PlanBoard.java 强>
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
import com.smartgwt.client.widgets.form.fields.DateItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.layout.VLayout;
public class PlanBoard extends VLayout {
public PlanBoard(){
preparaDetallePlan();
preparaAtributosPlan();
preparaSecciones();
}
private void preparaDetallePlan(){
StaticTextItem np = new StaticTextItem("id2", "Nombre de Plan:");
StaticTextItem npText = new StaticTextItem("id2", "Plan B");
ComboBoxItem tcBox = new ComboBoxItem();
tcBox.setTitle("Tipo de Carta");
tcBox.setWidth(250);
ComboBoxItem prBox = new ComboBoxItem();
tcBox.setTitle("Periodo");
prBox.setWidth(150);
StaticTextItem dp = new StaticTextItem("id3", "Descripcion:");
TextAreaItem dpText = new TextAreaItem();
dpText.setShowTitle(false);
dpText.setWidth(600);
dpText.setStartRow(true);
dpText.setEndRow(true);
dpText.setColSpan(2);
DynamicForm form = new DynamicForm();
form.setItems(np, npText, tcBox, prBox, dp, dpText);
form.setIsGroup(true);
form.setGroupTitle("DETALLES DE PLAN");
addMember(form);
}
private void preparaAtributosPlan(){
StaticTextItem fe = new StaticTextItem("id4", "Firma Electornica:");
CheckboxItem feCheck = new CheckboxItem();
feCheck.setShowTitle(false);
DateItem feFechaIni = new DateItem();
DateItem feFechaFin = new DateItem();
feFechaIni.setUseTextField(true);
DynamicForm form = new DynamicForm();
form.setItems(fe, feCheck, feFechaIni, feFechaFin);
form.setIsGroup(true);
form.setGroupTitle("ATRIBUTOS DE PLAN");
addMember(form);
}
private void preparaSecciones(){
DynamicForm form = new DynamicForm();
form.setIsGroup(true);
form.setGroupTitle("SECCIONES");
addMember(form);
}
}
TestCases.java (重命名为您未指定的EntryPoint类名称):
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.CloseClickEvent;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.layout.VLayout;
import com.google.gwt.core.client.EntryPoint;
public class TestCases implements EntryPoint {
public void onModuleLoad() {
IButton tester = new IButton("Tester");
tester.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final Window win = new Window();
win.setTitle("Ventana Tester");
win.setWidth(900);
win.setHeight(600);
win.setIsModal(true);
win.setShowModalMask(true);
win.centerInPage();
win.setMinimized(false);
win.addCloseClickHandler(new CloseClickHandler() {
@Override
public void onCloseClick(CloseClickEvent event) {
win.destroy();
}
});
PlanBoard pb = new PlanBoard();
win.addItem(pb);
win.show();
}
});
VLayout vlPrincipal = new VLayout();
vlPrincipal.addMember(tester);
vlPrincipal.draw();
}
}
一些注意事项:
DynamicForm
控件。你试图做的很多事情,你做的比实际困难更多。