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
2b507253
Commit
2b507253
authored
Jan 30, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2225 from thiagotalma/master
Allow to set an attribute as the value of the cell, unlike the column attribute
parents
e6831371
8c49dabb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
DataColumn.php
framework/grid/DataColumn.php
+7
-2
No files found.
framework/grid/DataColumn.php
View file @
2b507253
...
...
@@ -40,7 +40,8 @@ class DataColumn extends Column
*/
public
$label
;
/**
* @var \Closure an anonymous function that returns the value to be displayed for every data model.
* @var string|\Closure the attribute name to be displayed in this column or an anonymous function that returns
* the value to be displayed for every data model.
* The signature of this function is `function ($model, $index, $widget)`.
* If this is not set, `$model[$attribute]` will be used to obtain the value.
*/
...
...
@@ -140,7 +141,11 @@ class DataColumn extends Column
protected
function
renderDataCellContent
(
$model
,
$key
,
$index
)
{
if
(
$this
->
value
!==
null
)
{
$value
=
call_user_func
(
$this
->
value
,
$model
,
$index
,
$this
);
if
(
is_string
(
$this
->
value
))
{
$value
=
ArrayHelper
::
getValue
(
$model
,
$this
->
value
);
}
else
{
$value
=
call_user_func
(
$this
->
value
,
$model
,
$index
,
$this
);
}
}
elseif
(
$this
->
content
===
null
&&
$this
->
attribute
!==
null
)
{
$value
=
ArrayHelper
::
getValue
(
$model
,
$this
->
attribute
);
}
else
{
...
...
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