Flexgrid Scroll to row

Posted by: paulo.dias on 28 September 2017, 1:03 am EST

  • Posted 28 September 2017, 1:03 am EST

    Hello.

    I’m using the grid and I need to do scroll to some row.

    I tried to use the method “ScrollIntoView” and it worked when for example I click in a button in my View.

    I’m having difficulty to use that method when I create my grid. I need to create the datasource and instantly do scroll for the user have visible some row.

    I tried to do that scroll in some grid methods with no success.

    What’s the best way to do that?

    Thanks in advance for the help one more time.

    Regards,

    Paulo Dias

  • Posted 28 September 2017, 1:22 am EST

    Hi Paulo

    Maybe try using the Appearing event that Xamarin provides. I think that’s the first life cycle event where you could trigger it.

  • Posted 1 October 2017, 7:54 pm EST

    Hello.

    Thanks for your help. I can scroll to some row using the “ScrollIntoView” method.

    But I found a problem. The scroll works well vertically, but it scrolls always to the second column.

    I tried in the Flexgrid Sample, and the same occurs. The first column is always hidden when I use the value “0”. If I use more than “0” it shows the third, fourth, etc.

    This problem is known?

    Thanks, again for your help.

    Regards,

    Paulo Dias

  • Posted 2 October 2017, 4:12 am EST

    Hi Paulo

    Are you experiencing this in Xuni or C1 Xamarin? We’re not issuing updates to Xuni anymore (since the C1 Xamarin product supersedes it) so you might want to migrate to the new platform if you’re seeing problems. One suggestion that might work (without the migration) is trying to use the Select method instead. It can perform a similar function as ScrollIntoView and may work better in this circumstance.

  • Posted 3 October 2017, 10:28 pm EST

    Hi

    I am currently migrating to C1 grid. It’s not going to be simple because my grid has a lot of customization.

    The old version has DoubleTap Event.

    I also have other problem. I the old version, I can do:

    public override void OnSortedColumn(GridCellRangeEventArgs args)

    I use this method to save some grid configuration, for the next time the user use the grid.

    But I will try to read the documentation and explore better the new grid.

    Thanks for your help.

    Regards,

    Paulo Dias

  • Posted 4 October 2017, 4:29 am EST

    Hi Paulo

    The C1 Xamarin controls should still have a CellDoubleTapped event that you can use.

    http://help.grapecity.com/componentone/NetHelp/XamarinEdition/C1.Xamarin.Forms.Grid~C1.Xamarin.Forms.Grid.FlexGrid~CellDoubleTapped_EV.html

    Also if you need to capture when the FlexGrid is sorted you can used the CollectionView SortChanged event as below:

    grid.ItemsSource = new C1CollectionView<Customer>(Customer.GetCustomerList(100));
    grid.AllowSorting = true;
    ((C1CollectionView<Customer>)(grid.ItemsSource)).SortChanged += GridSortChanged;
    
  • Posted 4 October 2017, 7:31 am EST

    Here are a couple of alternatives. You could shorten my code above to:

    
    grid.ItemsSource = Customer.GetCustomerList(100);
    grid.AllowSorting = true;
    ((C1CollectionView<object>)(grid.CollectionView)).SortChanged += GridSortChanged;
    
    

    You could also use the following extension methods:

    
    public static void AttachSortChanged<T>(this ICollectionView<T> collectionView, EventHandler handler) where T : class
    {
        (collectionView as ISupportSorting).SortChanged += handler;
    }
     
    /// <summary>
    /// Dettaches the specified handler from the sort changed event.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="collectionView">The collection view.</param>
    /// <param name="handler">The event handler.</param>
    public static void DettachSortChanged<T>(this ICollectionView<T> collectionView, EventHandler handler) where T : class
    {
        (collectionView as ISupportSorting).SortChanged -= handler;
    }
    
    

    And then use code like the following to attach it:

    
    grid.ItemsSource = Customer.GetCustomerList(100);
    grid.AllowSorting = true;
    grid.CollectionView.AttachSortChanged(GridSortChanged);
    
    
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels