我想知道当我们点击gxt中的日期字段时,是否有更改弹出的日历的位置?我的日历在外面的某个地方弹出,而不是在日期字段附近弹出。
答案 0 :(得分:0)
您可以尝试使用setPosition(x,y)移动日历,也可以尝试使用alignTo方法,如下所示:
DatePicker dp = new DatePicker();
dp.setPosition(100, 100);
dp.getElement().alignTo(yourTextField.getElement(), new AnchorAlignment(Anchor.BOTTOM), null);
答案 1 :(得分:0)
My code is a bit lengthier so i'm just posting the part of code where i used Date.
final Date currentDate = new Date();
dateFrom = new DateField();
dateFrom.setValue(currentDate);
dateFrom.setEditable(false);
dateFrom.setWidth(90);
final FieldLabel fldf = new FieldLabel(dateFrom, messages.dateFrom());
fldf.setLabelWidth(70);
dateFrom.addParseErrorHandler(new ParseErrorHandler() {
@Override
public void onParseError(ParseErrorEvent event) {
Info.display(messages.parseError(), event.getErrorValue()
+ messages.parseDateError());
}
});
final HorizontalLayoutContainer hc1 = new HorizontalLayoutContainer();
hc1.insert(fldf, 1, new HorizontalLayoutData(-1, 1, new Margins(20,0,0));
final VerticalLayoutContainer vlc = new VerticalLayoutContainer();
vlc.insert(oneMessageLabel, 0);
vlc.insert(twoMessageLabel, 1);
vlc.insert(threeMessageLabel, 2);
vlc.insert(hc1, 3);
final FramedPanel fpSearch = new FramedPanel();
fpSearch.setHeadingText("Search");
fpSearch.setPixelSize(995,160);
fpSearch.setStyleName("xframedPanelDash");
fpSearch.add(vlc);
FormPanel formPanel = new FormPanel();
formPanel.add(fpSearch);
final HorizontalLayoutContainer hcErrorPanel = new HorizontalLayoutContainer();
hcErrorPanel.insert(formPanel, 0, new HorizontalLayoutData(-1, 1,
new Margin(70,0,0,10));
vlc = new VerticalLayoutContainer();
vlc.setScrollMode(ScrollMode.AUTO);
vlc.add(hcErrorReportPanel);
initWidget(vlc);