Select SfDataGrid row only on double click

Right now, when I click on sfdatagrid, it get selected by single click. How can I make sure it only get selected when user double clicks ?

I'm aware of CellDoubleTapped method, but I want to avoid it.

1 Reply 1 reply marked as answer

MA Mohanram Anbukkarasu Syncfusion Team November 25, 2020 07:42 AM UTC

Hi John, 

Thanks for Contacting Syncfusion support.  

There is not direct property to achieve your requirement. However You can make the rows in the SfDataGrid to select only when user double clicks on the row by using the SelctionChanging, SelectionChanged and CellDoubleTapped events of the SfDataGrid as shown in the following code example.  

Code example :  

<syncfusion:SfDataGrid Name="dataGrid" 
                       SelectionChanging="DataGrid_SelectionChanging" 
                       SelectionChanged="DataGrid_SelectionChanged" 
                       CellDoubleTapped="DataGrid_CellDoubleTapped" 
                       ItemsSource="{Binding OrdersListDetails}"/> 
 
bool isDoubleTapped; 
 
private void DataGrid_SelectionChanging(object sender, Syncfusion.UI.Xaml.Grid.GridSelectionChangingEventArgs e) 
{ 
    if (!isDoubleTapped) 
        e.Cancel = true; 
} 
 
private void DataGrid_CellDoubleTapped(object sender, Syncfusion.UI.Xaml.Grid.GridCellDoubleTappedEventArgs e) 
{ 
    isDoubleTapped = true; 
    this.dataGrid.SelectedIndex = this.dataGrid.ResolveToRecordIndex(e.RowColumnIndex.RowIndex); 
} 
 
private void DataGrid_SelectionChanged(object sender, Syncfusion.UI.Xaml.Grid.GridSelectionChangedEventArgs e) 
{ 
    isDoubleTapped = false; 
} 


Please let us know if you require any other assistance from us.  

Regards, 
Mohanram A. 


Marked as answer
Loader.
Up arrow icon