How can I have different swipeMaxOffset by swiping left or right ?

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.


7 Replies

NK Neelakandan Kannan Syncfusion Team September 28, 2021 09:46 AM UTC

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,

https://www.syncfusion.com/feedback/29009/support-to-set-the-swipe-offset-individually-for-left-and-right-swiping

We appreciate your patience until then.

Regards,

Neelakandan



NK Neelakandan Kannan Syncfusion Team September 28, 2021 11:17 AM UTC

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



FA Fanny September 30, 2021 07:45 PM UTC

Hi,


Thank you for your quick answer. It was exactly what I needed. 


Best regards.



SR Sangeetha Raju Syncfusion Team October 1, 2021 06:42 AM UTC

Hi Fanny, 
 
Thanks for your update. 
 
We are glad to know that our solution meets your requirement. As we said earlier, we will implement this feature in our 2021 Volume 4 release. We will intimate you once its rolled out. Please get back to us if you require any further assistance. We will be happy to assist you. 
 
Regards, 
Sangeetha Raju. 



SR Sangeetha Raju Syncfusion Team December 20, 2021 09:56 AM UTC

Hi Fanny, 
 
We are glad to announce that your requested feature with Support to set the swipe offset individually for left and right swiping was included in our Essential Studio 2021 Volume 4 Main Release V19.4.0.38 is rolled out and is available for download under the following link. 
 
 
Now, you can use different swipe offset for left and right swipe direction. Please refer the following UG link for further information.  
 
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Sangeetha Raju. 



DO David OGUNDEPO January 17, 2023 10:13 AM UTC

Hello Sangeetha, can I use your assistance with the Datagrid widget, please?



SP Sangavi Periyannan Syncfusion Team January 17, 2023 12:49 PM UTC

David,

Please include more details about your query.  This would be helpful for us to serve you.


Loader.
Up arrow icon