test.com/index.php?r=material/admin&id=20000
then the application will need to set CGridView's page to where item with ID = 20,000 exists. So, if it is in page 200, then user will be showed page 200 of CGridView when going to that URL.
What I have tried:
1. Find item in CGridView's data provider.
2. Calculate page number of that item (where it exists).
3. Set page number of CGridView's data provider.
$dataProvider->pagination = false;
// find ID in current data provider (in the example ID = 20,000)
$index = array_search($id, $dataProvider->keys);
// calculate the correct page number (maximum items in 1 page = 10)
if ($index < 10)
$page = 0;
else
$page = ceil(($index+1)/10) - 1;
$dataProvider->pagination->currentPage = $page;
Although working correctly, that approach takes too much memory (that raises Memory Exhausted error) when it deals with a lot of data. Is there a more efficient way to get page number of specific item?

Help















