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
b8747b9e
Commit
b8747b9e
authored
Dec 19, 2014
by
Nobuo Kihara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs/guide/output-data-widgets.md - revised [ci skip]
parent
2081d0e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
output-data-widgets.md
docs/guide/output-data-widgets.md
+10
-10
No files found.
docs/guide/output-data-widgets.md
View file @
b8747b9e
...
...
@@ -73,29 +73,29 @@ the data provider. The displayed table is equipped with sorting and pagination f
Yii grid consists of a number of columns. Depending on column type and settings these are able to present data differently.
These are defined in the
columns
part of GridView configuration like the following:
These are defined in the
`columns`
part of GridView configuration like the following:
```
php
echo
GridView
::
widget
([
'dataProvider'
=>
$dataProvider
,
'columns'
=>
[
[
'class'
=>
'yii\grid\SerialColumn'
],
//
A simple column
defined by the data contained in $dataProvider.
// Data from the model's column
1
will be used.
//
Simple columns
defined by the data contained in $dataProvider.
// Data from the model's column will be used.
'id'
,
'username'
,
// More complex one.
[
'class'
=>
'yii\grid\DataColumn'
,
// can be omitted, default
'class'
=>
'yii\grid\DataColumn'
,
// can be omitted,
as it is the
default
'value'
=>
function
(
$data
)
{
return
$data
->
name
;
//$data['name'] for array data, e.g. using SqlDataProvider.
return
$data
->
name
;
//
$data['name'] for array data, e.g. using SqlDataProvider.
},
],
],
]);
```
Note that if the
columns part of the configuration isn't specified, Yii tries to show all possible data provider model columns
.
Note that if the
`columns`
part of the configuration isn't specified, Yii tries to show all possible columns of the data provider's model
.
### Column classes
...
...
@@ -111,9 +111,9 @@ echo GridView::widget([
],
```
In addition to column classes provided by Yii that we'll review below you can create your own column classes.
In addition to column classes provided by Yii that we'll review below
,
you can create your own column classes.
Each column class extends from
[
[\yii\grid\Column
]
] so there are some common options you can set while configuring
Each column class extends from
[
[\yii\grid\Column
]
] so th
at th
ere are some common options you can set while configuring
grid columns.
-
`header`
allows to set content for header row.
...
...
@@ -151,7 +151,7 @@ echo GridView::widget([
],
[
'attribute' => 'birthday',
'format' =>
[
'date', 'Y-m-d'
]
'format' =>
[
'date', '
php:
Y-m-d'
]
],
],
]);
...
...
@@ -159,7 +159,7 @@ echo GridView::widget([
In the above, `text` corresponds to [[\yii\i18n\Formatter::asText()]]. The value of the column is passed as the first
argument. In the second column definition, `date` corresponds to [[\yii\i18n\Formatter::asDate()]]. The value of the
column is, again, passed as the first argument while 'Y-m-d' is used as the second argument value.
column is, again, passed as the first argument while '
php:
Y-m-d' is used as the second argument value.
For a list of available formatters see the [section about Data Formatting](output-formatter.md).
...
...
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