如何根据行项目设置Vaadin Grid Pro中的“编辑”项目中的不同选择项目

发布于 2025-01-23 01:53:50 字数 218 浏览 5 评论 0原文

我有网格专业展示产品。单列被配置为“选择”类型(下拉/combobox)类型的编辑。我正在尝试根据该行的产品设置此组件的项目。使用“ Select” EditColumn可以做到这一点?

我试图使用网格的“ AddCelleDitStartEdlistener”事件来实现我想要的目标,但是我似乎无法从CellEditStartEdedEvent访问EditComponent ..

THX!

I have Grid Pro displaying Products. A single column is configured as an EditColumn of type 'select' (dropdown/combobox). I'm trying to set the items for this component based on the Product of that row. Is this possible using the 'select' editColumn?

I tried to achieve what I want using the grid's 'addCellEditStartedListener' event, but I can't seems to access the editComponent from CellEditStartedEvent..

thx!

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

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

发布评论

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

评论(1

感性 2025-01-30 01:53:50

是的,这是celleditStartedEvent中缺少的功能。作为替代方案,您可以在编辑列中使用自定义编辑器,因为您可以参考您使用的字段,请参见示例

    // Use custom editor
    EmailField emailField = new EmailField();
    emailField.setWidth("100%");
    emailField.addThemeName("grid-pro-editor");
    grid.addEditColumn(Person::getEmail)
            .custom(emailField, (item, newValue) -> {
                item.setEmail(newValue);
            }).setHeader("E-mail ");
    // Use edit started listener to set the field conditionally enabled
    grid.addCellEditStartedListener(event -> {
        if (!event.getItem().isSubscriber()) {
            emailField.setReadOnly(true);
        } else {
            emailField.setReadOnly(false);
        }
    });

此处: https://cookbook.vaadin.com/grid-pro-conditional-edit

Yes, the this is missing feature in CellEditStartedEvent. As an alternative you can use custom editor in your edit column, as then you have reference to the field you are using, see example

    // Use custom editor
    EmailField emailField = new EmailField();
    emailField.setWidth("100%");
    emailField.addThemeName("grid-pro-editor");
    grid.addEditColumn(Person::getEmail)
            .custom(emailField, (item, newValue) -> {
                item.setEmail(newValue);
            }).setHeader("E-mail ");
    // Use edit started listener to set the field conditionally enabled
    grid.addCellEditStartedListener(event -> {
        if (!event.getItem().isSubscriber()) {
            emailField.setReadOnly(true);
        } else {
            emailField.setReadOnly(false);
        }
    });

Full code here: https://cookbook.vaadin.com/grid-pro-conditional-edit

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