gpt4 book ai didi

Vaadin - 表列顺序

转载 作者:行者123 更新时间:2023-12-04 14:01:28 24 4
gpt4 key购买 nike

任何人都知道如何/或有可能 - 创建一个具有特定列顺序的表;保存之前的配置顺序 - 数据库中的示例,
并在特定 View 上上传?我也想知道如何从 POJOS 类 - bean 生成此列标题和内容。

有什么好主意吗?

最佳答案

setVisibleColumns
Table::setVisibleColumns 有双重职责:

  • 控制哪些列可见,以及
  • 设置列出现的顺序。

  • 调用 Table::getVisibleColumns 查看当前订单。

    文件

    这在以下内容中有很好的描述:
  • Book of Vaadin > Table
  • Sampler > User Interface > Data Presentation > Table
  • Table API JavaDoc

  • 示例代码

    基本上,您需要这样的代码来控制列顺序并将 bean 实例列表设置为数据源。

    代码未经测试 ,只是示范。适用于 Vaadin 6,但我想与 Vaadin 7 相比没有显着变化。
    table = new Table();

    // Wrap your beans collection into vaadin data container. There are many
    // types of them , check Book of Vaadin.
    BeanItemContainer<Bean> container = new BeanItemContainer<Bean>(Bean.class)
    container.addBean(new Bean());

    // Set collection of your beans as data source.
    // Columns will be created for each property, vaadin uses reflection.
    table.setContainerDataSource( container );

    // You can select to display only properties you want, not all.
    // Order matters. You can get columns list from any source - for example
    // store in your DB.
    table.setVisibleColumns( new Object[] {"prop1", "prop2"} );

    // You can set column headers (by default vaadin will set them same as bean
    // properties names). Order matters, should match above order.
    table.setColumnHeaders( new String[] {"Property 1", "Property2"} );

    关于Vaadin - 表列顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19528880/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com