Revision #208 was created by rackycz on Jul 3, 2020, 12:46:05 PM.
GridViev - Variable page size
Content
[...]
GridView cannot display DropDownList which could be used by the user to change the number of rows per page. You have to add it manually like this:
When you are creating a new model using Gii, you can select if you want to create the SearchModel as well. Do it, it is usefull for example in this situation. Then add following rows to the model:
public function getPageSizeDropDownID($prefix = '#') {
return $prefix . Html::getInputId($this, 'pageSize');
}
// This function already exists, so change it:
public function search($params)
{
// ..
$this->load($params);
// Add following rows:
if (!isset($this->pageSize)) {
// Here we make sure that the dropDownLst will have correct value preselected
$this->pageSize = $dataProvider->pagination->defaultPageSize;
}