Reloading the ItemsSource does not reposition the grid items

Changing the contents of ItemsSource does not scroll the datagrid to the top left.  If you have been scrolling the datagrid it will stay where it was and is beyond confusing for a user.

Is there a way to do this until it is fixed?





5 Replies

KK Karthikraja Kalaimani Syncfusion Team October 17, 2022 10:15 AM UTC

Hi LIoyd, 

The scroll position does not start from 0 when change the ItemSource because it is default behavior of DataGrid. However, you can reposition the ScrollView to 0 by programmatic scrolling after the ItemSource is changed. Please, refer to the below code snippets to achieve your requirement and we have also attached the working sample for your reference.

Code snippets : 

            (this.dataGrid.Children[0] as ScrollView).ScrollToAsync(0, 0, false);

 
Regards,
Karthik Raja


Attachment: SfDataGridDemo_b7d2ac0c.zip


LS Lloyd Sheen October 17, 2022 06:10 PM UTC

It is not the behaviour of the Xamarin DataGrid , or basically any other datagrid I have seen.  This behaviour is simply terrible.


What you suggest takes MVVM and throws it out the window.  The code you shows is dependent on code which would have to be in every View that uses a DataGrid.

This is a must have feature of a datagrid.



KK Karthikraja Kalaimani Syncfusion Team October 18, 2022 02:13 PM UTC

Hi Lloyd, 

Currently, we are validating the behaviour with Xamarin forms DataGrid. We will validate and update the further details on or before 20th Oct 2022. We appreciate your patience until then.

Regards,
Karthik Raja




KK Karthikraja Kalaimani Syncfusion Team October 21, 2022 03:58 AM UTC


Hi Lloyd,


We have planned to change the behaviour of scroll position when ItemSource is changed by exposing public API which will decide to maintain or reset the scroll position when ItemSource is changed. We have logged feature request for the same and we will implement the feature in our upcoming 2022 Volume 4 release which is scheduled on mid of December 2022. We appreciate your patience until then.

You can track the status of this report through the following feedback link, https://www.syncfusion.com/feedback/38504/provide-support-to-reset-or-maintain-the-scroll-position-when-itemsource-is

Regards,

Karthik Raja



KK Karthikraja Kalaimani Syncfusion Team December 22, 2022 10:38 AM UTC

We are glad to announce that our Essential Studio 2022 Volume 4 Main Release V20.4.0.38 is rolled out with "Provide support to reset or maintain the Scroll position based on the CanMaintainScrollPosition property like in Xamarin Forms DataGrid" feature and it is available for download under the following link.

 

You can set the CanMaintainScrollPosition property value as false to reset the scroll position whenever the ItemsSource is changed. For more details, please refer to the below code snippets. 


Code snippets: 

 <syncfusion:SfDataGrid x:Name="data" ItemsSource="{Binding OrderInfoCollection}" CanMaintainScrollPosition="False"> </syncfusion:SfDataGrid>

 

 

We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance


Loader.
Up arrow icon