This is a migrated thread and some comments may be shown as answers.

Load on demand ios list scroll to top

4 Answers 72 Views
This is a migrated thread and some comments may be shown as answers.
RR
Top achievements
Rank 1
RR asked on 19 Sep 2018, 05:45 AM

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"

4 Answers, 1 is accepted

Sort by
0
RR
Top achievements
Rank 1
answered on 20 Sep 2018, 05:47 AM

hi,

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

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

 

0
Yana
Telerik team
answered on 20 Sep 2018, 08:38 AM
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
0
RR
Top achievements
Rank 1
answered on 20 Sep 2018, 12:29 PM

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

0
Yana
Telerik team
answered on 25 Sep 2018, 03:01 PM
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

Asked by
RR
Top achievements
Rank 1
Answers by
RR
Top achievements
Rank 1
Yana
Telerik team
Share this question
or