syncfusion / flutter-widgets

Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.6k stars 786 forks source link

Flutter Syncfusion DataGridview how to Find Colum Name of Sorted Index. #2157

Open abdulrehmananwar opened 3 weeks ago

abdulrehmananwar commented 3 weeks ago

Use case

Retrieve Sorted Column Name I would like to request a feature that provides the ability to easily retrieve the name of the column selected for sorting in the Syncfusion DataGrid. This would allow developers to dynamically identify which column is being sorted and perform relevant actions based on the sorted column.

Auto-Adjust Column Width on Double-Click A feature to automatically adjust the width of a column when its resize handle is double-clicked would greatly enhance user experience. This behaviour should dynamically fit the column's width to its content, similar to how spreadsheet applications handle column resizing.

Conditional Column Width Mode Based on Cell Values It would be beneficial to have an option where ColumnWidthMode.fitByCellValue applies only when cell values are not empty. For columns with blank values, the width should default to ColumnWidthMode.fitByColumnName. This ensures optimal use of space and improves readability by avoiding overly wide columns due to a few non-empty cells while maintaining consistent width for columns with primarily empty values.

Need to Find the Filtered Rows Count i need to get the count of Filtered Rows. if i get DataGrid Rows Count it still showing me total rows. not length of filtered.

Proposal

image image image

abineshPalanisamy commented 3 weeks ago

Hi @abdulrehmananwar ,

Query Response
Retrieve Sorted Column Name Please refer to the following Knowledge Base link for a deeper understanding of How to retrieve the details of sorted columns in Flutter DataTable. You can customize the provided code to suit your specific requirements. KB link -  sorted columns
Need to Find the Filtered Rows Count Please refer to the following Knowledge Base link for a deeper understanding of How to display the total row count at the bottom, with active filtering in Flutter DataTable. You can customize the provided code to suit your specific requirements. KB link - Total row count
Conditional Column Width Mode Based on Cell Values To achieve conditional column width based on columnWidthMode for each GridColumn, you can implement a function that determines the appropriate mode for each column based on its cell values. This function will return either ColumnWidthMode.fitByCellValue or ColumnWidthMode.fitByColumnName for each column, depending on the content of the cells. We have included a sample for your reference. Please review it for further details.
Auto-Adjust Column Width on Double-Click We have a workaround to achieve the required behavior using the onCellDoubleTap callback. This callback is triggered when a cell is double-tapped. In this implementation, it checks if the double tap occurred on the header row (the first row, index 0). If so, it sets the width of the column to double.nan, which instructs the grid to automatically adjust the column width to fit the content. Additionally, please note that you need to have focus on the respective header or double-tap directly on the respective header cells. We have included a sample for your reference. Please review it for further details.

Regards, Abinesh P

abdulrehmananwar commented 1 week ago

op Double Click its resize some time and some time it resize some one else column

https://github.com/user-attachments/assets/5a216c84-a9c2-48af-b4b8-5f3315db07f0

abineshPalanisamy commented 2 days ago

Hi @abdulrehmananwar ,

In SfDataGrid, direct support for Auto-Adjust Column Width on Double-Click is not available. However, we have provided a workaround to achieve this behavior. As mentioned in our previous response, please note that you need to focus specifically on the respective header cell or double-tap directly on it. Based on the video provided, it appears that the focus was on a nearby header cell, which caused the auto-adjust feature to behave incorrectly. To resolve this, ensure that the focus is set explicitly on the header cell you want to adjust.

We achieved this functionality by utilizing the onCellDoubleTap callback. When the focus is on the respective header cell, this callback triggers the auto-adjust action.

Regards, Abinesh P