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.
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:

Created:

Updated:

Platform:

Replies:

124963 Jul 11,2016 01:09 PM UTC Jul 12,2016 02:27 PM UTC Xamarin.Android 1
loading
Tags: SfDataGrid
Steve
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.SetImageResource(Resource.Drawable.Undo);
swipeViewImage.SetBackgroundColor(Color.ParseColor("#1AAA87"));
swipeViewImage.Click += swipeViewImage_Click;
TextView swipeViewText = new TextView(context);
swipeViewText.Text = "Delete";
swipeViewText.Gravity = GravityFlags.Center;
swipeViewText.SetTextColor(Color.White);
swipeViewText.SetBackgroundColor(Color.ParseColor("#1AAA87"));
viewModel = new SwipingViewModel();
viewModel.SetRowstoGenerate(100);
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);
swipe.AddView(linear);
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";
sfGrid.Columns.Add(OrderID);
sfGrid.Columns.Add(CustomerID);
sfGrid.Columns.Add(EmployeeID);
sfGrid.Columns.Add(Name);
sfGrid.Columns.Add(ShipCity);
sfGrid.Columns.Add(ShipCountry);
sfGrid.Columns.Add(Freight);
frame.AddView(sfGrid);
return frame;
}
Any assistance appreciated.
Regards
Steve

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.

Regards,
Vimal Prabhu

CONFIRMATION

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.

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

;