I have a problem that I don't know how to do pagination for this table where only information I got is how many results should be shown and what is the current page or what is the last record (or last group).
The thing is that I don't want for example to get the first 5 records but I want all records of the first 5 groups but records and groups can be removed, sorted in any order or filtered so I can't use ID or group ID columns to determine from which ID to which ID I want to paginate)
ID - Group (FK) - value
------------------------
1 - 1 - a
2 - 1 - b
3 - 2 - c
4 - 2 - d
5 - 3 - e
6 - 2 - f
8 - 3 - g
9 - 2 - h
10 - 5 - i
11 - 5 - j
So when I want to get for example the second page and first 2 groups it should return:
ID - Group (FK) - value
------------------------
5 - 3 - e
8 - 3 - g
10 - 5 - i
11 - 5 - j
Or the first page of 3 groups
ID - Group (FK) - value
------------------------
1 - 1 - a
2 - 1 - b
3 - 2 - c
4 - 2 - d
5 - 3 - e
6 - 2 - f
8 - 3 - g
9 - 2 - h
Or the second page of 3 groups
ID - Group (FK) - value
------------------------
10 - 5 - i
11 - 5 - j
But when the table is sorted for example:
ID - Group (FK) - value
------------------------
3 - 2 - c
4 - 2 - d
10 - 5 - i
11 - 5 - j
5 - 3 - e
1 - 1 - a
2 - 1 - b
6 - 2 - f
8 - 3 - g
9 - 2 - h
Now I want the first 2 groups of page 1 it should return
ID - Group (FK) - value
------------------------
3 - 2 - c
4 - 2 - d
10 - 5 - i
11 - 5 - j
6 - 2 - f
9 - 2 - h