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

[syncfusion_flutter_datagrid] Customizable Footer (tableSummaryRows) : Show at the bottom when list has insufficient data #2235

Open
gltiennd opened this issue Dec 31, 2024 · 5 comments
Labels
data grid Data grid component waiting for customer response Cannot make further progress until the customer responds. workaround available Workaround available to overcome the query

Comments

@gltiennd
Copy link

Use case

Screenshot 2024-12-31 at 14 14 54

Proposal

Screenshot 2024-12-31 at 14 14 54

@gltiennd gltiennd changed the title [syncfusion_flutter_datagrid] Customizable Footer: Show at the bottom when list has insufficient data [syncfusion_flutter_datagrid] Customizable Footer (tableSummaryRows) : Show at the bottom when list has insufficient data Dec 31, 2024
@VijayakumarMariappan VijayakumarMariappan added data grid Data grid component open Open labels Jan 2, 2025
@abineshPalanisamy
Copy link

Hi @gltiennd ,

In SfDataGrid, the footer is an additional row that can be displayed under the last row. Widgets can be shown in this additional row by setting the SfDataGrid.footer property. The footer being added as the last row is the expected behavior of the DataGrid.

However, we have a workaround to achieve this behavior on our end. When there is insufficient data, you can add a custom widget, like a footer, in the build method to display at the bottom of the screen. When the rows are scrollable, you can use the SfDataGrid.footer property. In the SfDataGrid.footer, you should only add the custom widget. This workaround helps achieve the desired behavior.

We have provided sample for your reference. Please refer to the attached sample for more details.

Sample : SfDataGrid.zip

Regards,
Abinesh P

@ashok-kuvaraja ashok-kuvaraja added waiting for customer response Cannot make further progress until the customer responds. workaround available Workaround available to overcome the query and removed open Open labels Jan 2, 2025
@gltiennd
Copy link
Author

gltiennd commented Jan 2, 2025

This is not the desired result. I would like it to be associated with changing the width. @abineshPalanisamy b

@abineshPalanisamy
Copy link

Hi @gltiennd ,

To display a footer in the SfDataGrid and associate it with changing the width, you can customize the widget used for the footer. The width of the footer can be dynamically adjusted to match your requirements by wrapping it in a container and setting its width property accordingly.

We have included a code snippet for your reference. Please refer to the code for more details.

  @override
  Widget build(BuildContext context) {
    final double footerWidth =
        MediaQuery.of(context).size.width * 0.8; // Adjust based on requirements

    return Scaffold(
      appBar: AppBar(
        title: const Text('Syncfusion Flutter DataGrid'),
      ),
      body: Column(
        children: [
          Expanded(
            child: SfDataGrid(
              source: employeeDataSource,
              columnWidthMode: ColumnWidthMode.fill,
              footer: isFooterEnabled
                  ? Align(
                      alignment: Alignment.center,
                      child: Container(
                        width: footerWidth, // Dynamic width for the footer
                        color: Colors.grey[400],
                        child: const Center(
                          child: Text(
                            'FOOTER VIEW',
                            style: TextStyle(fontWeight: FontWeight.bold),
                          ),
                        ),
                      ),
                    )
                  : null,
              columns: <GridColumn>[
                GridColumn(
                    columnName: 'id',
                    label: Container(
                        padding: const EdgeInsets.all(16.0),
                        alignment: Alignment.center,
                        child: const Text('ID'))),
                GridColumn(
                    columnName: 'name',
                    label: Container(
                        padding: const EdgeInsets.all(8.0),
                        alignment: Alignment.center,
                        child: const Text('Name'))),
                GridColumn(
                    columnName: 'designation',
                    label: Container(
                        padding: const EdgeInsets.all(8.0),
                        alignment: Alignment.center,
                        child: const Text(
                          'Designation',
                          overflow: TextOverflow.ellipsis,
                        ))),
                GridColumn(
                    columnName: 'salary',
                    label: Container(
                        padding: const EdgeInsets.all(8.0),
                        alignment: Alignment.center,
                        child: const Text('Salary'))),
              ],
            ),
          ),
          if (!isFooterEnabled)
            Align(
              alignment: Alignment.center,
              child: Container(
                height: 50,
                width:
                    footerWidth, // Same dynamic width as the DataGrid footer.
                color: Colors.grey[400],
                child: const Center(
                  child: Text(
                    'FOOTER VIEW',
                    style: TextStyle(fontWeight: FontWeight.bold),
                  ),
                ),
              ),
            ),
        ],
      ),
    );
  }

If you are still encountering issues, if there are any misunderstandings regarding your requirements, or if your needs differ, please provide specific and detailed information about the expected behavior. This should include how you need to display the footer and how you wish to customize it. Providing this additional information will help us address your request comprehensively and offer an appropriate solution.

Regards,
Abinesh P

@gltiennd
Copy link
Author

gltiennd commented Jan 3, 2025

The list I can drag horizontally. I appreciate if you fix it with buildTableSummaryCellWidget
Screenshot 2025-01-03 at 18 13 38 @abineshPalanisamy b

@abineshPalanisamy
Copy link

Hi @gltiennd ,

In SfDataGrid, the table summary row always appears next to the DataGridRow. We provide support for moving the table summary to the top or bottom of the DataGrid by using the GridTableSummaryRow.position property.

In your case, you need to display the table summary row at the bottom of the screen. Unfortunately, this cannot be achieved directly through the table summary, as it is always attached to the grid. This is the expected behavior.

To achieve the desired layout, we have provided a workaround using the footer. If you need any assistance with this implementation or have further questions, please don’t hesitate to reach out. We’re happy to help!.

Regards,
Abinesh P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data grid Data grid component waiting for customer response Cannot make further progress until the customer responds. workaround available Workaround available to overcome the query
Projects
None yet
Development

No branches or pull requests

4 participants