Dev-Owl / advanced_datatable

Advanced Datatable uses the Fultter PaginatedDataTable Widget and adds a few more functions to it

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to change already displayed items?

opened this issue · comments

Hi,
I have been working for quite some time now to initialize this paginateddatatable with 1400 elements via SQL. In principle, I find it very strange when neither states nor providers are used in the examples and nothing is cached here.

The following article also provided an aha experience #1 because as soon as filters are to be used, the paging no longer works.

In the absence of examples and strange behaviors xD I have more questions.

Question
How can I edit a table row that is displayed? Where do I start?

Thx for hints
Chris

There is a state, the current page is cached. That's the idea, only have the minimum of data in the app. There is full support for filters and nothing breaks, the example includes a full working version of it.

Just keep in mind, filters are, like the complete control, designed to be server side. Simple said they happen outside of the tables code. With your use case I would think of a class that contains the logic to build up and run a query including paging in SQLite. It would be important to run the filter, sorting and paging in SQLite to prevent loading all data.

To answer your second step editing a row would be roughly done like this:

  1. Handle the tap event on data row or via an included widget like a button
  2. Provide the data via the tap to the editing widget
  3. Update your backend with the new data if saved
  4. Trigger a reload for the current page ( se filter examples)

The reload is required as the changes might move the row to a new page (filter, order). If you actually really want to manipulate the state of data and do just a client side redraw it is also possible (see the checkbox example for client side reload). The row data would be found in the lastDetails property of your data source.

For client side reload you can find and update the data in the mentioned property and trigger the state reload. Please note, depending on filters and sorting the updated row might no longer "fit" in the table.

Hope that helped you, if not I can try to generate an example once I have time ( close to release for my main project and it eats a lot of time)

Closing, feel free to reopen if further questions come up about this topic