Horizontal ListView doesn't scroll to an index

Hi,

I have a horizontal SfListView with grouping and I scroll to a position, when I add a picture to the list. I use the code from your web page:

int index = listView.DataSource.DisplayItems.IndexOf(viewModel.Customers[2]);
listView.LayoutManager.ScrollToRowIndex(index, Syncfusion.ListView.XForms.ScrollToPosition.Center, true); It worked in previous version of the library 16.2..... but now nothing happens. Regards Marian

7 Replies

JN Jayaleshwari N Syncfusion Team October 4, 2018 03:56 PM UTC

Hi Marian, 
 
Thanks for using Syncfusion products. 
 
We have analyzed your query based on the information you provided from our end. Unfortunately the reported issue is not reproduced at our end. We have attached the sample we have checked for your reference. ScrollToRowIndex is working as expected. 
 
 
Can you please check with the above sample? whether you are facing similar issue in our sample. If no, we would request you to modify the sample which would highly helpful to us to analyze the issue better and update you an appropriate solution.     
  
Regards,   
Jayaleshwari N  



MG Marian Grzesik October 11, 2018 10:28 AM UTC

Hi,

your example works fine, but it doesn't use grouping. I've found some strange thing connected to the horizontal ListView.
If I add an Element to a ObservableCollection and use the Insert function:

Images.Insert(index-1, newItem);

the horizontal ListView is showing the new item always at the end, even though I inserted the item before the last element.  I see in debugger the ViewModel Collection is correct, but the control shows the last two elements in a wrong order.

ViewModel:  …...Image1, Image2
View:             …..Image2, Image1

This is the reason for the problem in the scrolling. 

Thanks
Marian 


JN Jayaleshwari N Syncfusion Team October 12, 2018 07:31 AM UTC

Hi Marian,  
 
Thanks for the update. 
 
We have checked your query “The new image always at the end even though I inserted the item before the last element ” from our end. You can achieve your requirement by adding item in specific group items in case of GroupDescriptior added for ListView. Since the collection you maintained in ViewModel and DisplayElements are different when Grouping is enabled. 
 
We have attached the modified sample for your reference. You can download the same form the following location. 
 
 
We have already documented about this use case in our documentation. You can refer from the following location 
 
 
Please let us know if this solution meets your requirement. 
 
Regards, 
Jayaleshwari N. 



MG Marian Grzesik October 17, 2018 07:46 AM UTC

Hi,

thanks for the examples. They work fine, even though they are very simplistic. With the example I could create an example, where the items are correct grouped, but in iOS the list doesn't want to move to the right index. It is very frustrated. 

The problem is also another, the API to group the list and to move it to an index should be fully supported from the ViewModel. It is not possible to get the right sequence of the items in the list in ViewModel and on the GUI, when grouping is used. I have to change the list of items on the GUI (with your example it is possible) to get the right sequence with grouping. It is not a well design. It is especially to see the bad design, if you try to create a view with a horizontal list, where you can add real photos to any index and any group, add new groups etc. In ViewModel it is not a problem, but than to change the items in the GUI to get the expected result is not acceptable. It would be better if the control would change the API to support the grouping and moving to an index in ViewModel.

Thanks
Marian 


JN Jayaleshwari N Syncfusion Team October 18, 2018 12:08 PM UTC

  
We would like to let you know that internally we processed the grouping inside our ListView source and we are maintain the items in DisplayItems property as like in the UI. This is the default behavior of ListView. If you want to get the items with group, you can get it by using DisplayItems property of DataSource. And also you find the index from that property and you can scroll to specific item.   
  
If your adding a new item into the listview, it will be automatically added into the last item of group based on the Key of the group. If you want to add an item to specific index then you need to find the group and add it. Kindly follow the UG link which is provided in the previous update.  
 
#  in iOS the list doesn't want to move to the right index 
 
We have checked this from the attached sample. Unfortunately the reported issue not reproduced at our end. Could you please share the Xaml, ViewModel code snippet that modified which would highly help us to resolve the issue. 
  
Regards,  
Jayaleshwari N 



MG Marian Grzesik November 1, 2018 12:57 PM UTC

Hi,

I've created an sample app, which adds images to a group or creates a new group. The app needs rights to the picture gallery. The app works well in Android, but in iOS the items can't be move in code to the right index. The right index is the index of a "+" image in the list, in a specific group, where the last picture was added.

The example of a well architecture for a grouping is the ListView from UWP. 

Thanks
Marian

Attachment: GHList_f345868e.zip


RS Rawoof Sharief Muthuja Sherif Syncfusion Team November 2, 2018 12:33 PM UTC

Hi Marian,  
  
We have checked the attached sample and found that the issue is due to the renderer is not initialized in the iOS project. You can initialize the SfListViewRenderer in the AppDelegate file which resolves the reported issue.  
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate  
    {  
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)  
        {  
            global::Xamarin.Forms.Forms.Init();  
            SfListViewRenderer.Init();  
            FFImageLoading.Forms.Platform.CachedImageRenderer.Init();  
            LoadApplication(new App());  
  
            return base.FinishedLaunching(app, options);  
        }  
    }  
  
Please follow the below link for more detail about launching listview on each platform.  
  
  
Regards,  
Rawoof M.  
 


Loader.
Up arrow icon