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

SfDataGrid - Swipe enable only on specific rows.

Hi, I have a data set that contains some elements that are editable/deletable and others that are not. I am displaying these elements using the SfDataGrid. I've enabled swiping and have left and right swipe working. However, its working on all the rows. Is there a way of specifying which rows in the grid should allow swiping?

The best I have manged so far is to make the content of the SwipeTemplate DataTemplate bind IsVisible to the row data so that when the readonly row is swiped there is nothing displayed in the swipe area but the row still swipes.

Ideally I'd like for the read only rows not to swipe at all.

Something along the lines of a QuerySwiping event with a cancel property would do what I need.

Thanks

1 Reply

SP Subburaj Pandian Veluchamy Syncfusion Team August 12, 2019 07:06 AM UTC

Hi Christopher,  
  
Thank you for contacting Syncfusion support. 
 
To cancel swiping for a row based on the conditions you can use SfDataGrid.SwipeStarted event where you can cancel the swiping of the row. 
 
Please refer the following code, 
 
[C#] 
private void DataGrid_SwipeStarted(object sender, SwipeStartedEventArgs e) 
{ 
               //// Here you can get the desired row data, row index of the swiping row. 
               var rowData = e.RowData; 
               var direction = e.SwipeDirection; 
               if(e.RowIndex < 6) 
               { 
                              //// You can cancel the swiping of the row. 
                              e.Cancel = true; 
               } 
}               
 
We have prepared a sample based on your requirement and you can download it from the below link, 
 

We hope this helps. Please let us know, if you would require any further assistance. 
 
Regards,
Subburaj Pandian V  
 


Loader.
Up arrow icon