Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DataGrid widget #178

Open
ecton opened this issue Oct 10, 2024 · 1 comment
Open

Add DataGrid widget #178

ecton opened this issue Oct 10, 2024 · 1 comment

Comments

@ecton
Copy link
Member

ecton commented Oct 10, 2024

While the Grid widget is good for smaller lists and provides very flexible layout options, some applications need to be able to display lists that have an order of magnitude larger amount of data that isn't feasible to load into memory in one chunk.

While the Grid widget has access to all of its children, this widget will not. It must make layout decisions without being able to ask all of the children for their measurements. We need to abstract access to the data using a DataSource trait that might look something like:

pub trait DataSource {
  fn len(&self) -> usize;
  fn load(&self, indexes: RangeInclusive<usize>) -> Vec<WidgetList>;
}

This interface does not attempt to solve widget reuse. Overall, I don't believe the allocations on a per-row basis should be worried about. The major savings of this widget is to avoid loading millions of widgets at a time.

Other problems that need to be considered:

  • Column management. How do the data source and the data grid agree on columns? Is the user just expected to make this work? Does the data grid support changing columns or does that require creating a new data grid with a new data source?
  • Row heights. Without knowing the height of each row, we can't determine the total scrollable area or how much each pixel of movement of the scrollbar impacts scrolling the list. Many frameworks force a consistent row height. Some make some concessions to allow flexible row heights. I would prefer flexible row heights, but also am happy to keep things simple.
  • Headers/Footers: We should probably have support for one or more header and footer rows that do not scroll with the list.

Ideally we can share code between the Grid and Stack. For that reason, it may make sense to tackle this after #126.

@ecton
Copy link
Member Author

ecton commented Nov 8, 2024

In #202 a VirtualList widget has been added. It doesn't support columns yet and is currently fixed row-height. But it probably can be used as the basis for a columnar data grid widget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant