Load on demand ios list scroll to top

5 posts, 0 answers
  1. RR
    RR avatar
    49 posts
    Member since:
    Apr 2012

    Posted 19 Sep 2018 Link to this post

    I use LoadonDemand in RadListView. in Event_ListLoadonDemand I call get method which is triggered when user click the load more button at the end of the list. this works fine is Android. But in ios when button is clicked events are concat to the list but list scrolls to the top.  This is not the case in android. How to avoid the list scrolling to the top in ios?  

     

    <telerikDataControls:RadListView x:Name="EventList"
                                          BackgroundColor="{StaticResource DarkGray}"
                                          ItemsSource="{Binding CalendarEvents,Mode=TwoWay}"
                                          VerticalOptions="FillAndExpand"
                                          HorizontalOptions="FillAndExpand"
                                          IsLoadOnDemandEnabled="True"
                                          LoadOnDemandMode="Manual"
                                          IsPullToRefreshEnabled="True"
                                          RefreshRequested="EventList_RefreshRequested"
                                          LoadOnDemand="EventList_LoadOnDemand"
  2. RR
    RR avatar
    49 posts
    Member since:
    Apr 2012

    Posted 20 Sep 2018 Link to this post

    hi,

    Actual problem could be  List.ScrollItemIntoView(lastItem);   is not working for ios. 

    This works in android as expected. Any work around for this?

     

  3. Yana
    Admin
    Yana avatar
    5013 posts

    Posted 20 Sep 2018 Link to this post

    Hello Roshan,

    Actually we've been reported a similar issue with ScrollIntoView method on iOS, you could check the exact case in the feedback item below:
    https://feedback.telerik.com/Project/168/Feedback/Details/255856-listview-ios-scrollitemintoview-scrolls-to-incorrect-item-when-itemtemplate-is

    Can you confirm you have the same scenario at your side? If the case is different, I would like to request more details (such as the implementation of the LoadOnDemand  and RefreshRequest event handlers), which will help us reproduce it.

    Looking forward to your reply.

    Regards,
    Yana
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  4. RR
    RR avatar
    49 posts
    Member since:
    Apr 2012

    Posted 20 Sep 2018 Link to this post

    hi,

    I tried without itemtemplate. Its the same behavior then too. Here s my xaml 

    <ContentView.Content>
    <Grid>
     
    <telerikDataControls:RadListView x:Name="EventList"
    BackgroundColor="{StaticResource DarkGray}"
    ItemsSource="{Binding CalendarEvents,Mode=TwoWay}"
    VerticalOptions="FillAndExpand"
    HorizontalOptions="FillAndExpand"
    IsLoadOnDemandEnabled="True"
    LoadOnDemandMode="Manual"
    IsPullToRefreshEnabled="True"
    RefreshRequested="EventList_RefreshRequested"
    LoadOnDemand="EventList_LoadOnDemand"   >
            <telerikDataControls:RadListView.ItemTemplate>
                        <DataTemplate>
                        <telerikListView:ListViewTemplateCell>
                            <telerikListView:ListViewTemplateCell.View>
                                 <Label Text="{Binding Name}"/>
                            </telerikListView:ListViewTemplateCell.View>
                        </telerikListView:ListViewTemplateCell>
                    </DataTemplate>
                    </telerikDataControls:RadListView.ItemTemplate>
       <telerikDataControls:RadListView.LoadOnDemandItemTemplate>
                        <DataTemplate>
    <Grid BackgroundColor="LightGray" HorizontalOptions="CenterAndExpand">
    <Label  HorizontalOptions="CenterAndExpand"  Text="Load More" HorizontalTextAlignment="Center" FontSize="Large" Margin="50,0,0,0"/>
    </Grid>
                      </DataTemplate>
        </telerikDataControls:RadListView.LoadOnDemandItemTemplate>
       </telerikDataControls:RadListView>
      <StackLayout IsVisible="{Binding IsBusy}"
                         BackgroundColor="Transparent"
                         Padding="12"
                         VerticalOptions="Center"
                         HorizontalOptions="Center">
     
                    <ActivityIndicator x:Name="busyindicator"
                                   IsRunning="{ Binding IsBusy }"
                                   Color="{StaticResource BrandColor}"/>
     
              </StackLayout>
     </Grid>
    </ContentView.Content>

     

    in code behind I have refresh_requested & loadondemand events.

    private async void EventList_RefreshRequested(object sender, PullToRefreshRequestedEventArgs e)
    {
        var vm = (CalendarViewModel)ViewModel;
        await vm.GetEvents();
        EventList.EndRefresh(false);
    }
     
    private async void EventList_LoadOnDemand(object sender, EventArgs e)
    {
        var vm = (CalendarViewModel)ViewModel;
        await vm.GetEvents();
        EventList.EndRefresh(false);
     
        ObservableCollection<EventModel> items = (ObservableCollection<EventModel>)EventList.ItemsSource;
        var lastItem = items.OrderByDescending(x => x.StartDateTime).FirstOrDefault();
        if (lastItem != null)
        {
            EventList.ScrollItemIntoView(lastItem);               
        }
    }

     

    I have applied ScrollItemIntoView(lastItem) which works fine in android. 

    Hope this will help.

    Thank you

  5. Yana
    Admin
    Yana avatar
    5013 posts

    Posted 25 Sep 2018 Link to this post

    Hello Roshan,

    Thank you for sending the requested snippets.

    I think we both refer to the same use case, as in the provided xaml there is an ItemTemplate defined.  Please follow the feedback item, so you would receive an email notification as soon as there is any progress on it.

    Let me know if I can assist with anything else.

    Regards,
    Yana
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items

Back to Top