Commit d9b256d7 by Jin Hu

Fixed pagination not working before data loaded

parent 220db270
......@@ -48,6 +48,7 @@ abstract class DataProvider extends Component implements DataProviderInterface
if ($this->id !== null) {
$this->_pagination->pageVar = $this->id . '-page';
}
$this->_pagination->totalCount = $this->getTotalCount();
}
return $this->_pagination;
}
......
......@@ -85,4 +85,21 @@ class ActiveDataProviderTest extends DatabaseTestCase
$provider->refresh();
$this->assertEquals(2, count($provider->getModels()));
}
public function testPaginationBeforeModels()
{
$query = new Query;
$provider = new ActiveDataProvider(array(
'db' => $this->getConnection(),
'query' => $query->from('tbl_order')->orderBy('id'),
));
$pagination = $provider->getPagination();
$this->assertEquals(1, $pagination->getPageCount());
$this->assertCount(3, $provider->getModels());
$provider->getPagination()->pageSize = 2;
$this->assertEquals(3, count($provider->getModels()));
$provider->refresh();
$this->assertEquals(2, count($provider->getModels()));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment