如何在 Vaadin 日期选择器的弹出窗口中仅显示年份和月份,而不显示日期?

发布于 2025-01-13 07:23:23 字数 138 浏览 4 评论 0原文

如何在 Vaadin 日期选择器的弹出窗口中仅显示年份和月份,而不显示日期? 有这样的可能吗? 请参阅屏幕截图中的示例

How to display only years and months without days in a pop-up window in Vaadin datepicker?
Is there such a possibility?
See the example in the screenshot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苦笑流年记忆 2025-01-20 07:23:23

DatePicker 没有这种功能,至少目前是这样。实现一年零一个月的弹出窗口的最简单方法可能是带有两个选择组件的对话框。

        Dialog dialog = new Dialog();
        List<String> collect = IntStream.rangeClosed(2000, 2022).boxed()
                .map(integer -> integer.toString()).collect(Collectors.toList());
        Select<String> yearSelect = new Select<String>(collect.toArray(new String[0]));
        Select<String> monthSelect = new Select<>("Jan", "Feb", "...");
        dialog.add(yearSelect, monthSelect);
        dialog.open();

DatePicker doesn't have that kind of functionality, at least at the moment. Probably the easiest way to implement a popup for a year and a month would be a Dialog with two Select components.

        Dialog dialog = new Dialog();
        List<String> collect = IntStream.rangeClosed(2000, 2022).boxed()
                .map(integer -> integer.toString()).collect(Collectors.toList());
        Select<String> yearSelect = new Select<String>(collect.toArray(new String[0]));
        Select<String> monthSelect = new Select<>("Jan", "Feb", "...");
        dialog.add(yearSelect, monthSelect);
        dialog.open();

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文