We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

onCurrentCellActivating

Hi, onCurrentCellActivating callback not working, I want to disable row selection and hide checkbox   based on some condition 


2 Replies 1 reply marked as answer

TP Tamilarasan Paranthaman Syncfusion Team January 3, 2023 01:00 PM UTC

Hi Awais,


Based on the information you provided, we were unable to reproduce the reported issue. We tested the following sample, and it was working correctly on our end. Please check the following code snippet and sample.


  @override

  Widget build(BuildContext context) {

    return Scaffold(

      appBar: AppBar(

        title: const Text('Flutter SfDataGrid'),

      ),

      body: SfDataGrid(

        source: _employeeDataSource,

        columns: getColumns,

        selectionMode: SelectionMode.multiple,

        navigationMode: GridNavigationMode.cell,

        columnWidthMode: ColumnWidthMode.fill,

        onCurrentCellActivating: (newRowColumnIndex, oldRowColumnIndex) {

          if (newRowColumnIndex.columnIndex == 1) {

            return false;

          }

          return true;

        },

      ),

    );

  }


Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample1892929281


In this sample, we have restricted row selection when selecting a cell in the "ID" column. To ensure that the onCurrentCellActivating callback is working correctly, please make sure that you have set the SfDataGrid.navigationMode to GridNavigationMode.cell.


If you are already using the GridNavigationMode.cell mode and are still experiencing issues, please provide us with more details about your use case and the behavior you are seeing. We would appreciate it if you provided a simple sample. This will help us better understand the issue and assist you in finding a solution.


To cancel row selection based on certain conditions when using the GridNavigationMode.row mode, you can use the onSelectionChanging callback. This callback is called before a row is selected, and you can return false from the callback to cancel the selection for the corresponding row.


For more information on the onSelectionChanging callback, please see the following API documentation:


API documentation: https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/SfDataGrid/onSelectionChanging.html


We have also provided detailed information on the onSelectionChanging callback in our user guide. You can find this information at the following URL:


UG Document: https://help.syncfusion.com/flutter/datagrid/selection#callbacks


Regards,

Tamilarasan


Marked as answer

AI Awais Ishaq replied to Tamilarasan Paranthaman January 4, 2023 07:31 AM UTC

thanks, navigationMode: GridNavigationMode.cell, was missing,


so how can we hide check box also as per condition?


Loader.
Live Chat Icon For mobile
Up arrow icon