【问题标题】:Vaadin Flow Grid. How get the data/rows from gridVaadin 流网格。如何从网格中获取数据/行
【发布时间】:2018-08-06 13:22:14
【问题描述】:

我使用带有 DataProvider 的 Grid 和延迟加载将数据加载到网格中。

加载数据后如何从网格中获取数据?我的意思是,我需要从已经有数据的网格中获取数据。

我需要grid.get....之类的东西

谢谢。

【问题讨论】:

    标签: vaadin10 vaadin-flow


    【解决方案1】:

    我会使用 grid.getDataCommunicator().fetchFromProvider(..) 来返回项目流方法,请参阅此处的 API 规范:https://demo.vaadin.com/javadoc/com.vaadin/vaadin-core/10.0.2/com/vaadin/flow/data/provider/DataCommunicator.html#fetchFromProvider-int-int-

    【讨论】:

    • 谢谢,这个方法是受保护的,我不能这样做 grid.getDataCommunicator().fetchFromProvider(1,1);请给我一个完整的例子吗?
    【解决方案2】:

    从 Vaadin 17 开始,您可以使用 DataView API 获取 Grid 中当前显示的项目:

      GridDataView<Person> dataView = grid.getGenericDataView();
      Person item = dataView.getItem(42);
      // or get all shown items
      dataView.getItems().forEach(item -> export(item));
    

    这里是一个如何收集导出数据的示例:https://vaadin.com/docs/latest/flow/binding-data/data-provider/#accessing-currently-shown-items

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-03
      • 2021-09-27
      • 2013-01-13
      • 2012-09-27
      • 1970-01-01
      • 2014-05-16
      相关资源
      最近更新 更多