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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DataGrid swipe to delete. Does not work if grid is wider than screen.

Thread ID:





124963 Jul 11,2016 01:09 PM UTC Jul 12,2016 02:27 PM UTC Xamarin.Android 1
Tags: SfDataGrid
Asked On July 11, 2016 01:09 PM UTC

I am following the sample for the swipe delete but in the sample the grid is restricted to be the same width as the screen andsfGrid.AutoGenerateColumns = false;
I want to Autogenerate about 7 columns and so I have an AutoGenerateColumns handler. When the grid is rendered it is wider than the screen and the user can slide it to see all columns to the right. But when the user slides the grid all the way to the right and then slides a row further to the right the row does slide but the "Delete and "Undo" view (sfGrid.LeftSwipeView) is not displayed but the row is deleted from the grid. The sfGrid.RightSwipeView works as expected.
If I do not set the sfGrid.LeftSwipeView then the app crashes when the sfGrid.RightSwipeView swipe event is triggered.
This is difficult to explain but hopefully you understand what I am trying to achieve. I want the "Delete" and "Undo" view to be displayed for both left and right row swipes and I want to size my columns such that they will extend past the width of the screen.
Below is the modified GetSampleContent from the SwipeDelete SamplePage:
public override Android.Views.View GetSampleContent(Android.Content.Context context)
FrameLayout frame = new FrameLayout(context);
linear = new LinearLayout(context);
linear.Orientation = Orientation.Horizontal;
ImageView swipeViewImage = new ImageView(context);
swipeViewImage.Click += swipeViewImage_Click;
TextView swipeViewText = new TextView(context);
swipeViewText.Text = "Delete";
swipeViewText.Gravity = GravityFlags.Center;
viewModel = new SwipingViewModel();
sfGrid = new SfDataGrid(context);
sfGrid.GridStyle = new Dark();
//sfGrid.AutoGenerateColumns = false;
sfGrid.ItemsSource = (viewModel.OrdersInfo);
sfGrid.AllowSwiping = true;
//sfGrid.ColumnSizer = ColumnSizer.Star;
DisplayMetrics metrics = context.Resources.DisplayMetrics;
int width = metrics.WidthPixels;
sfGrid.MaxSwipeOffset = width;
swipe = new SwipeView(context);
linear.AddView(swipeViewText, sfGrid.MaxSwipeOffset / 2, (int)sfGrid.RowHeight);
linear.AddView(swipeViewImage, sfGrid.MaxSwipeOffset / 2, (int)sfGrid.RowHeight);
sfGrid.LeftSwipeView = swipe;
sfGrid.RightSwipeView = swipe;
sfGrid.SwipeEnded += sfGrid_SwipeEnded;
sfGrid.SwipeStarted += sfGrid_SwipeStarted;
sfGrid.AutoGeneratingColumn += DataGrid_AutoGeneratingColumn;
GridTextColumn CustomerID = new GridTextColumn();
CustomerID.MappingName = "CustomerID";
CustomerID.HeaderText = "Customer ID";
GridTextColumn OrderID = new GridTextColumn();
OrderID.MappingName = "OrderID";
OrderID.HeaderText = "Order ID";
GridTextColumn EmployeeID = new GridTextColumn();
EmployeeID.MappingName = "EmployeeID";
EmployeeID.HeaderText = "Employee ID";
GridTextColumn Name = new GridTextColumn();
Name.MappingName = "FirstName";
Name.HeaderText = "Name";
GridTextColumn ShipCity = new GridTextColumn();
ShipCity.MappingName = "ShipCity";
ShipCity.HeaderText = "Ship City";
GridTextColumn ShipCountry = new GridTextColumn();
ShipCountry.MappingName = "ShipCountry";
ShipCountry.HeaderText = "Ship Country";
GridTextColumn Freight = new GridTextColumn();
Freight.MappingName = "Freight";
Freight.HeaderText = "Freight";
return frame;
Any assistance appreciated.

Vimal Prabhu Manohkaran [Syncfusion]
Replied On July 12, 2016 02:27 PM UTC

Hi Steve,

Sorry for the inconvenience caused. We were able to reproduce the reported issue "DataGrid swipe to delete. Does not work if grid is wider than screen" and we have logged a issue report for the same. The fix for this issue will be available in the upcoming 2016 Volume 2 Service Pack release.

Vimal Prabhu


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon