Server-Side Paging in IgxGrid With Total Row Count
New DiscussionHi all,
I’m new in Ignite UI and I’m trying to apply load on demand feature wenn paging in the igx-grid.
I have a huge dataset, which a fetch from a service so I want to load just 50 rows per Page and when the user clicks next page, should the service fetch the next 50 rows.
The Problem is that the count of pages should be set according to the total count of remote data, NOT according to the loaded data (50 rows).
My Code and the Api are below:
Angular Component:
users: User[];
ngOnInit() { );
this._dataService.getdata(0).subscribe(data => { this.users = data.users; this.count=data.count; console.log(data)});
}
pageNext(event) {
this._dataService.getdata(event.current).subscribe(data => { this.users = data; });
}
Angular Service:
getdata(pageindex):Observable{
return this._http.post('http://localhost/values/GetUsers',pageindex);
}
WebApi:
[HttpPost]
public object GetUsers([FromBody] int pageIndex)
{
int userIndex = pageIndex * 50;
List users = new List();
users = _context.Users.ToList();
users = users.GetRange(userIndex, 50);
return new { users = users, count = _context.Users.Count() } ;
}
View Html:
Sign In
to post a reply
Replies
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Favorites
0 Replies
7 Created On
Apr 22, 2021 Last Post
5 years, 3 months ago