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

Scroll to last item or specific item

is it possible to scroll to last item in sfdatagrid? for example, i have list of items and I add a new item with a button click, how can I scroll to this item which is last one? Is there something like ScrollTo function Xamarin Forms listview has?

6 Replies

DS Divakar Subramaniam Syncfusion Team February 7, 2017 04:09 AM UTC

Hi Emil, 
 
 
Thanks for contacting Syncfusion Support. 
 
 
In SfDataGrid, it is possible to scroll to specific index using SfDataGrid.ScrollToRowColumnIndex() method by passing RowIndex and ColumnIndex as parameters. 
 
 
Please refer the below UG link to know more about programmatic scrolling. 
 
 
 
Regards, 
Divakar. 



DM Dan Meier February 23, 2017 04:52 AM UTC

What is the actual scrolling behavior?  When I use ScrollToRowIndex(RowIndex), I'd expect the grid to scroll so that the index row is at the top of the grid.  Similarly, with ScrollToColumnIndex(ColIndex), I'd expect the grid to scroll so that the index column is at the left of the grid.  However, neither of these behaviors happens consistently. The index row or column always seems to be in view, but not where I expect it.  It seems the scrolling behavior is non-deterministic.  What's really happening?


EM Emil February 26, 2017 03:34 AM UTC

Hi Dan,

these functions only work if SfDataGrid is already created in another words if Items are already bound. Therefore you can create it in the constructor and if you want to scroll to specific column/row, you can use  OnAppearing event. I hope that it helps you. 

Cheers,

Emil


EM Emil February 26, 2017 03:36 AM UTC

Hi Divakar,

I am mostly using mvvm and i would like to know if somehow I can achieve this in my viewmodel. I already achieved in xaml.cs as I wrote to my response to Dan. please let me know

thanks,

Emil 


AN Ashok N Syncfusion Team February 26, 2017 12:50 PM UTC

Hi Dan, 
 
We have checked your query and SfDataGrid to scroll based on the given RowIndex and View size. The given RowIndex to place the top of the view when the remaining records count more than the view size. Otherwise the given RowIndex comes to the View and that RowIndex was placed based on the View size because SfDataGrid always fit the View size. This is the same for ScrollToColumnIndex also.  
 
Please let us know if you require further assistance on this.  
 
Regards, 
Ashok 



AN Ashok N Syncfusion Team February 26, 2017 06:44 PM UTC

Hi Emil, 
 
You can use the ScrollToRowColumnInde method in your ViewModel class by using Button click in MVVM by adding command and command parameter to the button. Please refer the below KB link for Button.Command binding  
 
 
Regards, 
Ashok 


Loader.
Up arrow icon