Skip to content

Conversation

deepss1
Copy link

@deepss1 deepss1 commented Mar 14, 2024

Get pressed cell's RowColumnIndex details to better handle the row selection

deepss1 added 2 commits March 14, 2024 18:31
Get pressed cell's `RowColumnIndex` details to better handle the row selection
Get pressed cell's `RowColumnIndex` details to better handle the row selection
@deepss1
Copy link
Author

deepss1 commented Mar 14, 2024

Resolves issue #1041

Usage :

SfDataGrid(
...
  onSelectionChanging: (addedRows, removedRows, index) {
    // Allow selection only for the checkbox column 
    if (index.columnIndex == 0) {
      return true;
    }
    return false;
  },
...
)

@abineshPalanisamy
Copy link

Hi @deepss1 ,

Based on the information provided, you are expecting to allow selection only for the checkbox column. Currently, the DataGrid doesn’t support selecting rows only by the checkbox column. However, we have a workaround that can help you achieve your requirement. You can disable row selection by returning false from the onSelectionChanging callback, which will allow you to restrict the selection by tapping on other cells.

To select rows using checkboxes, we recommend not using the in-built DataGrid checkbox column. Instead, you can add a checkbox as the first column in the GridColumn collection. You can also add a checkbox for each corresponding row cell in the DataGridSource.buildRow method.

By wrapping a GestureDetector as a parent for the checkbox column, you can select rows programmatically on tap and double-tap using the DataGridController when the checkbox is selected.

We have attached the sample file for your reference. Please refer to the following sample for more information.

Regards,
Abinesh P

@ashok-kuvaraja ashok-kuvaraja added waiting for customer response Cannot make further progress until the customer responds. and removed open Open labels Mar 22, 2024
@deepss1
Copy link
Author

deepss1 commented Mar 22, 2024

@abineshPalanisamy

Thanks for your response.

I have checked this workaround as it was mentioned in the issue #1041

However, it also required me to implement a select all, un-select all, and show partially selected.

After achieving this behaviour, the data grid would automatically scroll to the last row after trying to select all rows.

To avoid over engineering the checkbox functionality, it made more sense having the RowColumnIndex in onSelectionChanging callback to decide whether the selection is to be triggered or not.

IMO this PR can be more convenient for the devs without any major change.

@abineshPalanisamy
Copy link

abineshPalanisamy commented Mar 27, 2024

Hi @deepss1,

As of now, we have considered your request as a feature. We will implement this feature. During the planning stage for every release cycle, we review all open features and identify those for implementation based on specific parameters, including product vision, technological feasibility, and customer interest. We appreciate your patience and understanding until then.

Regards,
Abinesh P

@ashok-kuvaraja ashok-kuvaraja added the uncertain Uncertain feature label Apr 2, 2024
@ashok-kuvaraja
Copy link
Collaborator

Hi @deepss1,

We are closing this issue now. If you need any further assistance, kindly reopen this issue. We are always happy to help you.

Regards,
Ashok K

@ashok-kuvaraja ashok-kuvaraja removed the waiting for customer response Cannot make further progress until the customer responds. label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data grid Data grid component uncertain Uncertain feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants