In my ngOnInit()
I have called the API in that API I got list of data. E.x : 26 data.
for (let i = 0; i < getUsersResponse.data.length; i++) {
let data = {
// ... I have set data based on my table which is works fine.
}
this.usersDataSource.append(data)
}
After append all data in source I want to dislay data from scratch. So for that I have set page.
this.usersDataSource.setPage(1);
this.usersDataSource.refresh();
Still I got last data range. I got data from 21 to 26 at first time. I don't know why it is not updating.
According to this, setPage doesn't work well; so you should use setPaging like this (for a pagesize of 20 items):
this.usersDataSource.setPaging(1, 20, true);
You don't need to call the refresh method because with the third argument set to true the refresh is automatic.
You could also try to use
this.usersDataSource.add(data);
instead of the append function. The append function sets the current page to the last; but the add function doesn't (watch this)