Get Data from server on scrolling

 I want to implement infinite  or Virtual Scrolling in angular, want to make http call to get first 10 items after scrolling div want to call http request to get next 10 items . Can you please guide me how to do this?

1 Reply

AG Ajith Govarthan Syncfusion Team May 8, 2020 02:12 PM UTC

Hi Ibrahim, 

Thanks for contacting Syncfusion forum. 

Based on your reported information you can achieve your requirement using the URL adaptor. In URL Adaptor at the initial load of the grid , the data are fetched from the remote data and bound to the grid using url property of DataManager. 

In your requirement you need to render first 100 records at initial rendering, so we suggest you to define the pageSize as 100 in pageSettings API.  In this case when reaching 100 items via scrolling next 100 items are generated after request comes from server side.  

Please refer to the below code and sample link: 

 
<ejs-grid #grid [dataSource]='data'  [enableInfiniteScrolling]='true'  height='400' [pageSettings]='pageSettings'> 
    <e-columns> 
. . . .  . 
    </e-columns> 
</ejs-grid> 
 
export class FetchDataComponent { 
    public data: any; 
    public pageSettings: object = { pageSize: 100 }; 
 
    ngOnInit(): void { 
        this.data = new DataManager({ 
            url: 'Home/UrlDatasource', 
            adaptor: new UrlAdaptor 
        }); 
    } 
} 
 


For more information about URL adaptor refer below link. 



Please get back to us, if you need any further assistance. 

Regards, 
Ajith G. 


Loader.
Up arrow icon