Use filtered dataProvider contents when FileDownloader is called in Vaadin

后端 未结 2 1459
不思量自难忘°
不思量自难忘° 2021-01-27 06:16

I\'m trying to download a csv file after applying filters to the DataProvider.

For some reason the filtered results are shown in the Grid, but the downloaded csv file s

2条回答
  •  Happy的楠姐
    2021-01-27 06:19

    Thank you for using Vaadin-on-Kotlin!

    I've just updated the Databases Guide which should hopefully answer all of your questions. If not, just let me know and I'll update the guides accordingly.

    1. The ListDataProvider.items will not apply any filters and will always return all items. You need to use the getAll() extension function in order to obey the filters set by the Grid. This is now explained in the Exporting data from DataProviders chapter of the Databases Guide.

    2. In your code, both the grid and the yearField will set the filter to the same data provider, thus overwriting values set by each other. Please read the Chaining Data Providers chapter in the Databases Guide to learn how to AND multiple filters set by multiple components.

    3. When you use private val dataProvider = DataProvider.ofCollection(FinancialTransaction.findAll()), that will load all transactions from the database in-memory. You can use a more memory-efficient way: private val dataProvider = FinancialTransaction.dataProvider (given that FinancialTransaction is an Entity)

    Please let me know if this answers your questions. Thanks!

提交回复
热议问题