Skip to content

Header columns wont scroll after shrinkWrapColumns is true #680

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

Closed
pluzmedia opened this issue Apr 19, 2022 · 8 comments
Closed

Header columns wont scroll after shrinkWrapColumns is true #680

pluzmedia opened this issue Apr 19, 2022 · 8 comments
Labels
data grid Data grid component workaround available Workaround available to overcome the query

Comments

@pluzmedia
Copy link

Header columns ain't scrollable after shrinkWrapColumns: true. How to achieve that?

@pluzmedia pluzmedia changed the title Header columns wont scroll after shrinkWrapColums is true Header columns wont scroll after shrinkWrapColumns is true Apr 19, 2022
@Tamilarasan-Paranthaman

Hi @pluzmedia,

Greetings from Syncfusion.

The Header columns will not be scrollable if you use the shrinkWrapColumns property. Because if you use shrinkWrapColumns, then the DataGrid sets its maximum width based on the available columns in the DataGrid, so all the columns are laid out. Please provide more details and a sample in case we misunderstood your requirement. It will be helpful for us to check on it and provide you with the solution at the earliest.

Regards,
Tamilarasan

@pluzmedia
Copy link
Author

So it's a limitation. I want to use use textfileds with focus node in the cells. Focusnodes got destroyed after scrolling the data grid horizontally, to over come this should to use shrinkWrapColumn but it has limitation.

@Tamilarasan-Paranthaman

Hi @pluzmedia,

If you’re using the focus node in the TextField and scrolling the DataGrid horizontally, the focus node will be destroyed. Because DataGrid will reuse the rows while scrolling. That’s why the focus node is destroyed. Can you please let us know the purpose of using the focus node in TextField? Also, please provide the exact details of your requirement. It will be helpful for us to check on it and provide you with the best solution at the earliest.

Regards,
Tamilarasan

@pluzmedia
Copy link
Author

We are using focusnode to navigate textfields by arrow key or enter button.

@Tamilarasan-Paranthaman
Copy link

Tamilarasan-Paranthaman commented Apr 22, 2022

Hi @pluzmedia,

You can achieve it by using the SingleChildScrollView Widget. Wrap the DataGrid as a child of the SingleChildScrollView and set the scrollDirection property to Axis.horizontal. It will allow you to scroll the header horizontally. Please check the following code snippet.

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: const Text('Syncfusion Flutter DataGrid')),
        body: SingleChildScrollView(
            scrollDirection: Axis.horizontal,
            child: SfDataGrid(
                  source: _employeeDataSource,
                  shrinkWrapColumns: true,
                  columns: getColumns),
            ));
  }

Also, we have published the KB article about how to perform vertical or horizontal scrolling in Flutter DataGrid by mouse dragging in web or desktop platforms. Please refer the following KB document,

KB link: https://www.syncfusion.com/kb/12893/how-to-perform-vertical-or-horizontal-scrolling-in-flutter-datatable-sfdatagrid-by-mouse

We hope this helps. Please let us know if you need any further assistance.

Regards,
Tamilarasan

@YancyHsu
Copy link

Hi @pluzmedia,

You can achieve it by using the SingleChildScrollView Widget. Wrap the DataGrid as a child of the SingleChildScrollView and set the scrollDirection property to Axis.horizontal. It will allow you to scroll the header horizontally. Please check the following code snippet.

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: const Text('Syncfusion Flutter DataGrid')),
        body: SingleChildScrollView(
            scrollDirection: Axis.horizontal,
            child: SfDataGrid(
                  source: _employeeDataSource,
                  shrinkWrapColumns: true,
                  columns: getColumns),
            ));
  }

Also, we have published the KB article about how to perform vertical or horizontal scrolling in Flutter DataGrid by mouse dragging in web or desktop platforms. Please refer the following KB document,

KB link: https://www.syncfusion.com/kb/12893/how-to-perform-vertical-or-horizontal-scrolling-in-flutter-datatable-sfdatagrid-by-mouse

We hope this helps. Please let us know if you need any further assistance.

Regards, Tamilarasan

use this method, frozenColumnsCount wont work

@VijayakumarMariappan VijayakumarMariappan added data grid Data grid component open Open labels May 23, 2025
@abineshPalanisamy
Copy link

Hi @YancyHsu ,

In SfDataGrid, when shrinkWrapColumns and shrinkWrapRows are enabled, the DataGrid sets its maximum width and height based on the available columns and rows. This causes all columns and rows to be laid out, removing the built-in scrollbars in both directions.

To enable scrolling, wrap the DataGrid in a SingleChildScrollView and set the appropriate scrollDirection. However, using SingleChildScrollView makes the entire grid scrollable, which disables the freeze pane feature of the DataGrid.

In this case, freeze panes are not applicable, and this is the expected behavior of the DataGrid when using shrinkWrap.

Regards,
Abinesh P

@ashok-kuvaraja ashok-kuvaraja added waiting for customer response Cannot make further progress until the customer responds. and removed open Open labels May 26, 2025
@ashok-kuvaraja
Copy link
Collaborator

Hi @pluzmedia,

We suspect that the reported issue has been resolved at your end. Hence, we are closing this issue. If you need any further assistance, please reopen this. We are always happy to help.

Regards,
Ashok K

@ashok-kuvaraja ashok-kuvaraja added workaround available Workaround available to overcome the query and removed waiting for customer response Cannot make further progress until the customer responds. labels Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data grid Data grid component workaround available Workaround available to overcome the query
Projects
None yet
Development

No branches or pull requests

7 participants