android loadmore manual issue

Thread is closed for posting
2 posts, 0 answers
  1. License
    License avatar
    43 posts
    Member since:
    Oct 2016

    Posted 20 Feb 2017 Link to this post

    Hi,can help me resolve android loadOnDemandMode Manual, in my project i have a SegmentedBar View show different type(in:50 records,out:12 records) data, in listview set 10
    records per page,and set loadmore tap text as 'loadmore' , i tap that and loaded the last record data,the tap text dismiss, when i tap SegmentedBar change to out tab ,just show 10 records,and yet not found  'loadmore', so have any way to show 'loadmore' and load more data ?

    in my code init list view 

    if (!this.listview) {
     
         this.listview = <RadListView>this.getPage().getViewById('listView');
    }
     
    if (this.listview && isAndroid) {
         this.listview.loadOnDemandMode = 'Manual';
         this.listview.resumeUpdates(true);
    } else {
        this.listview.loadOnDemandMode = 'Auto';
    }

     

    and when finish load data set  in onLoadMoreItemsRequested

    public onLoadMoreItemsRequested(args: ListViewEventData) {
       console.log('onLoadMoreItemsRequested', this.totalPage);
       if (this.currentPage < this.totalPage) {
        args.returnValue = true;
       } else {
         args.returnValue = false;
         console.log('args.returnValue:' + args.returnValue);
       }
    }

     so i found args.returnValue = false this code cause the tap 'loadmore' dismiss, but i don't know how to reappear 'loadmore'

     

  2. Nikolay Iliev
    Admin
    Nikolay Iliev avatar
    351 posts

    Posted 20 Feb 2017 Link to this post

    Hi License Concordya Team,

    As far as I understood your scenario, you have a SegmentedBar which controls your page different "inline" sections, and inside of each section, you have a RadListView with the loadOnDemandMode set to true.
    I am only guessing here but are you using the same RadListView and only updating the data source when changing the SegmentedBarItems on tap/swipe!? In my understanding when you hide the loadMore button with args.returnValue = false; you are forcingly telling the RadListView to hide the loadMore button and never show it again. 
    If that is understood correctly and your final goal is to reappear the loadMore button when navigating within the SegmentedBarItems, then you should not use args.returnValue but the loadOnDemandMode  enumeration for your RadListView. You can do this when selectedIndexChanged is triggered and changed.

    e.g. (based on the code in this example)
    let radList: RadListView = page.getViewById("radList");
    let segmentedBar: SegmentedBar = page.getViewById("segBar");
     
    segmentedBar.on("selectedIndexChanged", (args: SelectedIndexChangedEventData) => {
        radList.loadOnDemandMode = ListViewLoadOnDemandMode[ListViewLoadOnDemandMode.Manual];
    })

    where both the SegmentedBar and the RadListView are set with IDs in the XML file like:
    <SegmentedBar id="segBar" >
     
    <lv:RadListView id="radList">

    Now, whenever the selectedIndexChanged event fires (thus the user tabs and change the segmented bar items), the RadListView used will set its ListViewLoadOnDemandMode with Manual this way forcing the loadMore template to load. If you want by default to hide the loadMore button, then you can just provide None as the default mode. 

    e.g.
    radList.loadOnDemandMode = ListViewLoadOnDemandMode[ListViewLoadOnDemandMode.None];

    Using the different modes, you can specify in which case you want to load the Manual mode and in which you would want the None mode (where the loadMore template will not be visible).

    Regards,
    Nikolay Iliev
    Telerik by Progress
    Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
Back to Top