Hi,
I try to have a different swipeMaxOffset when I swipe from left and when I swipe to right.
Any ideas to do that ?
Thanks.
Hi Fanny,
Thanks for using Syncfusion products.
Currently, SfDataGrid does not have the support to set the different max offset values for left and right swiping. We have considered your request as feature and logged the feature request. We will implement this feature in our 2021 Volume 4 release which is scheduled to be rolled out on mid of December 2021. Please follow up with the below feedback link for further updates,
We appreciate your patience until then.
Regards,
Neelakandan
Hi Fanny,
You can set the different offset to the maxSwipeOffset property based on the right or left swiping using the onSwipeStart call back. You can use this solution for now. We will provide the built-in support to set the different offset for left or right swiping as promised in next release.
|
class _MyHomePageState extends State<MyHomePage> { List<Employee> employees = <Employee>[]; late EmployeeDataSource employeeDataSource; double swipeMaxOffset = 60;
@override void initState() { super.initState(); employees = getEmployeeData(); employeeDataSource = EmployeeDataSource(employeeData: employees); }
bool setSwipeOffset(DataGridRowSwipeDirection direction) { double currentOffset = direction == DataGridRowSwipeDirection.startToEnd ? 60 : 100; if (currentOffset != swipeMaxOffset) { swipeMaxOffset = currentOffset; setState(() {}); } return true; }
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Syncfusion Flutter DataGrid'), ), body: SfDataGrid( source: employeeDataSource, swipeMaxOffset: swipeMaxOffset, allowSwiping: true, onSwipeStart: (details) => setSwipeOffset(details.swipeDirection), startSwipeActionsBuilder: (context, row, index) { return Container( color: Colors.red, alignment: Alignment.center, child: Text('ADD)); }, endSwipeActionsBuilder: (context, row, index) { return Container( color: Colors.green, alignment: Alignment.center, child: Text('ADD')); }, columns: <GridColumn>[ GridColumn( columnName: 'id', label: Container( padding: EdgeInsets.all(16.0), alignment: Alignment.center, child: Text( 'ID', ))), GridColumn( columnName: 'name', label: Container( padding: EdgeInsets.all(8.0), alignment: Alignment.center, child: Text('Name'))), GridColumn( columnName: 'designation', label: Container( padding: EdgeInsets.all(8.0), alignment: Alignment.center, child: Text( 'Designation', overflow: TextOverflow.ellipsis, ))), GridColumn( columnName: 'salary', label: Container( padding: EdgeInsets.all(8.0), alignment: Alignment.center, child: Text('Salary'))), ], ), ); } |
Regards,
Neelakandan
Hi,
Thank you for your quick answer. It was exactly what I needed.
Best regards.
Hello Sangeetha, can I use your assistance with the Datagrid widget, please?
David,
Please include more details about your query. This would be helpful for us to serve you.