N
N
nepster-web2014-04-10 02:32:14
Yii
nepster-web, 2014-04-10 02:32:14

Yii2 GridView, how to change search view and add custom feature?

I use GridView in the admin panel.
It looks like this:
6728503d568c2e74634db6f649579946.jpg
When using search filters, the url looks like this:
538c2e8ed6c43e1c4f17fe19aa3ced2d.jpg
And then a few questions arose:
1) Can these search inputs and selects be moved to another place? (Well, for example, in a separate block on a site with pop-up show-offs, etc.?)
2) How can I finish this business so that, for example, to find all the articles that have more than 20 comments?
3) For example, if we have a module with articles and a user module. And there is a need to make a link in the user profile All articles of the user That
is, the filter should be by user_id. It turns out that you need to write something like this:

<a href="/admin/ModelSearch[user_id]=32">Все статьи пользователя</a>
Or is there a more elegant way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Zelenin, 2014-04-10
@nepster-web

1) you can modify the gridview in any way, by inheriting, and add your own js scripts
2) in short - not a problem (GridView + ModelSearch). You make a filter, add a variable to ModelSearch, process this variable in the search method.
3) do in any place religiously suitable for you (it is logical that it will be an article controller), an action with the $user_id argument and return a list of articles in it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question