how to reset the selected row for SelectionChanged

Hi,

Maybe I need to do it completely different but what I currently have is a dataGrid showing several records.
When I select one of them a popup is displayed with the contents of the record.
When I close the popup I cannot select the same record again to show the popup as the selection didn't change and therefor the SelectionChanged event isn't triggered again.
How can I overcome this? Is there a way to clear the which row was selected to force the SelectionChanged event to fire again?
Or maybe I need to use a different approach altogether?
As far as I can find there isn't a RowTapped event or something similar?


3 Replies 1 reply marked as answer

SD Sethupathy Devarajan Syncfusion Team January 22, 2025 01:35 PM UTC

Hi Alban Tilanus,

Thank you for contacting us,


Query

Response

When I select one of them a popup is displayed with the contents of the record.

When I close the popup I cannot select the same record again to show the popup as the selection didn't change and therefor the SelectionChanged event isn't triggered again.

 

 

You need to show the popup when selecting the same record again. You can achieve this by using the GridCellTapped event instead of SelectionChanged. We have shared a code snippet and a simple sample for your reference. Could you please review them and confirm whether they meet your requirements?

Code snippet:
 

private void sfGrid_CellTapped(object sender, Syncfusion.Maui.DataGrid.DataGridCellTappedEventArgs e)

{

    var employee = e.RowData as Employee;

    if (employee != null &&  sfGrid.SelectedRows.Contains(employee))

    {

        viewModel.UpdateSelectedEmployee(employee);

    }

}


Regards,
Sethupathy D.


Attachment: SfDataGridSample_b6ab9029.zip

Marked as answer

AT Alban Tilanus January 27, 2025 06:26 AM UTC

Works perfectly. 

I originally got confused by the name as I was looking for row selections so I didn't think about cell selections. 


Thanks! 



SD Sethupathy Devarajan Syncfusion Team January 28, 2025 07:12 AM UTC

Hi Alban,

 

We are glad to know that the provided solution worked at your end. Please let us know if you have any further queries on this. We are happy to help.


Regards,

Sethupathy D.


Loader.
Up arrow icon