Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
3cf5ffe4
Commit
3cf5ffe4
authored
May 13, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs about multiple grids on one page.
parent
3dd4e719
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
6 deletions
+41
-6
output-data-widgets.md
docs/guide/output-data-widgets.md
+41
-6
No files found.
docs/guide/output-data-widgets.md
View file @
3cf5ffe4
...
...
@@ -218,15 +218,15 @@ echo GridView::widget([
'dataProvider'
=>
$dataProvider
,
'columns'
=>
[
[
'class'
=>
'yii\grid\SerialColumn'
],
// <-- here
// ...
```
Sorting data
------------
### Sorting data
-
https://github.com/yiisoft/yii2/issues/1576
Filtering data
--------------
### Filtering data
For filtering data the GridView needs a
[
model
](
model.md
)
that takes the input from the filtering
form and adjusts the query of the dataprovider to respect the search criteria.
...
...
@@ -308,8 +308,7 @@ echo GridView::widget([
```
Working with model relations
----------------------------
### Working with model relations
When displaying active records in a GridView you might encounter the case where you display values of related
columns such as the post's author's name instead of just his
`id`
.
...
...
@@ -362,3 +361,39 @@ In `search()` you then just add another filter condition with `$query->andFilter
> Info: For more information on `joinWith` and the queries performed in the background, check the
> [active record docs on eager and lazy loading](active-record.md#lazy-and-eager-loading).
### Multiple GridViews on one page
You can use more than one GridView on a single page but some additional configuration is needed so that
they do not interfer.
When using multiple instances of GridView you have to configure different parameter names for
the generated sort and pagination links so that each GridView has its individual sorting and pagination.
You do so by setting the
[
[yii\data\Sort::sortParam|sortParam
]
] and
[
[yii\data\Pagination::pageParam|pageParam
]
]
of the dataProviders
[
[yii\data\BaseDataProvider::$sort|sort
]
] and
[
[yii\data\BaseDataProvider::$pagination|pagination
]
]
instance.
Assume we want to list
`Post`
and
`User`
models for which we have already prepared two data providers
in
`$userProvider`
and
`$postProvider`
:
```
php
use
yii\grid\GridView
;
$userProvider
->
pagination
->
pageParam
=
'user-page'
;
$userProvider
->
sort
->
sortParam
=
'user-sort'
;
$postProvider
->
pagination
->
pageParam
=
'post-page'
;
$postProvider
->
sort
->
sortParam
=
'post-sort'
;
echo
'<h1>Users</h1>'
;
echo
GridView
::
widget
([
'dataProvider'
=>
$userProvider
,
]);
echo
'<h1>Posts</h1>'
;
echo
GridView
::
widget
([
'dataProvider'
=>
$postProvider
,
]);
```
### Using GridView with Pjax
TDB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment