yii2-alphapager
yii2-alphapager copied to clipboard
GridView Filters
First, many thanks for your wonderful extension! It's pretty rare that you can install an extension, follow some very clear and simple directions, and have it totally work without any problems. You've done an excellent job.
I noticed, when I implemented your extension, that the standard filter input boxes immediately under the column headings in GridView remain but they cease to work. I suspect that it has something to do with substituting your ActiveProvider. Is there any way that I can get these to work? I really need the ability to search by columns other than the column used for the AlphaPager. (Even there, with a large dataset, I need the capability of searching.)
@LarryTX ,
In order to search with the GridView, your dataProvider needs to somehow be bound to the searchModel that extends your model.
Is this the case?
I have a similar issue. I'm using a search provider to enable filtering, but it only filters in the currently selected page i.e. 'A'. Is there a way select the page 'all' when filtering is active?
class UserSearch extends User
{
public function rules()
{
// only fields in rules() are searchable
return [
[['username', 'firstname', 'lastname'], 'safe'],
];
}
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
public function search($params)
{
$query = User::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => false,
'sort' => [
'defaultOrder' => [
'username' => SORT_ASC
],
'attributes' => ['username', 'firstname', 'lastname']
],
'alphaAttribute' => 'username'
]);
// load the search form data and validate
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
// adjust the query by adding the filters
$query->andFilterWhere(['like', 'username', $this->username])
->andFilterWhere(['like', 'firstname', $this->firstname])
->andFilterWhere(['like', 'lastname', $this->lastname]);
return $dataProvider;
}
}