pagination = false; $have_been_filtered = false; $this->prepare(true); // force read of next page $non_filtered_models = $this->getModels(); foreach($non_filtered_models as $model) { $filterModel = $callback($model); if($filterModel) { $have_been_filtered = true; $this->setTotalCount($this->getTotalCount() - 1); } else { $filtered_models[] = $model; $filtered_keys[] = $model->id; } } if($have_been_filtered) { $this->setModels($filtered_models); $this->setKeys($filtered_keys); } } }