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

horizontally scrollable cell #300

Open
jig-saw-yuki opened this issue Sep 4, 2024 · 2 comments
Open

horizontally scrollable cell #300

jig-saw-yuki opened this issue Sep 4, 2024 · 2 comments

Comments

@jig-saw-yuki
Copy link

Could you tell me if there is a way to add a horizontal scroll bar to a cell like below?
DataTable2 does not support the auto-resize for the cell width based on the cell contents, which truncates the contents. So, I would like to add a horizontal scroll bar as a workaround.

DataCell(
        Container(
          width: 150,
          child: SingleChildScrollView(
            scrollDirection: Axis.horizontal,
            child: Row(
              children: [
                Icon(Icons.star),
                SizedBox(width: 10),
                Text('Status 1'),
                SizedBox(width: 10),
                Icon(Icons.check),
                SizedBox(width: 10),
                Text('Status 2'),
                SizedBox(width: 10),
                Text('Status 3'),
              ],
            ),
          ),
        ),
      ),
@chenhaomun
Copy link

@jig-saw-yuki Does the minWidth parameter help in this case?

If set, the table will stop shrinking below the threshold and provide horizontal scrolling. Useful for the cases with narrow screens (e.g. portrait phone orientation) and lots of columns (that get messed with little space)

final double? minWidth;

Example usage:

PaginatedDataTable2(
  minWidth: 600.0,
  columns: const [
    DataColumn2(label: Text('A')),
  ],
  source: YourSource(),
),

@jig-saw-yuki
Copy link
Author

Hi @chenhaomun,

Thank you so much for your response!

Yes, I use the PaginatedDataTable2's minWidth and DataColumn2's fixedWidth as a workaround, which works.
However, because this column can be very long or very short, the fixedWidth must be set to the longer one. As a result, when there is only short content, a large blank space is created on the right side.

I know that PaginatedDataTable2 does not have the ability to adjust the column width based on the cell's content width. That's why I am seeking a way to add at least a horizontal scroll bar there.

Thanks,
Yuki

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

2 participants