Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Y
yii2bootstrap
Project
Project
Details
Activity
Releases
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
夏彬
yii2bootstrap
Commits
1398de3f
Commit
1398de3f
authored
Aug 02, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed DataColumn::type to format.
Added GridView::dataColumnClass.
parent
d1ebf655
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
GridView.php
framework/yii/widgets/GridView.php
+7
-5
DataColumn.php
framework/yii/widgets/grid/DataColumn.php
+2
-2
No files found.
framework/yii/widgets/GridView.php
View file @
1398de3f
...
@@ -26,6 +26,7 @@ class GridView extends ListViewBase
...
@@ -26,6 +26,7 @@ class GridView extends ListViewBase
const
FILTER_POS_FOOTER
=
'footer'
;
const
FILTER_POS_FOOTER
=
'footer'
;
const
FILTER_POS_BODY
=
'body'
;
const
FILTER_POS_BODY
=
'body'
;
public
$dataColumnClass
=
'yii\widgets\grid\DataColumn'
;
public
$caption
;
public
$caption
;
public
$captionOptions
=
array
();
public
$captionOptions
=
array
();
public
$tableOptions
=
array
(
'class'
=>
'table table-striped table-bordered'
);
public
$tableOptions
=
array
(
'class'
=>
'table table-striped table-bordered'
);
...
@@ -277,7 +278,7 @@ class GridView extends ListViewBase
...
@@ -277,7 +278,7 @@ class GridView extends ListViewBase
$column
=
$this
->
createDataColumn
(
$column
);
$column
=
$this
->
createDataColumn
(
$column
);
}
else
{
}
else
{
$column
=
Yii
::
createObject
(
array_merge
(
array
(
$column
=
Yii
::
createObject
(
array_merge
(
array
(
'class'
=>
DataColumn
::
className
()
,
'class'
=>
$this
->
dataColumnClass
,
'grid'
=>
$this
,
'grid'
=>
$this
,
),
$column
));
),
$column
));
}
}
...
@@ -300,14 +301,15 @@ class GridView extends ListViewBase
...
@@ -300,14 +301,15 @@ class GridView extends ListViewBase
*/
*/
protected
function
createDataColumn
(
$text
)
protected
function
createDataColumn
(
$text
)
{
{
if
(
!
preg_match
(
'/^(
\w+)(\s*:\s*(\w+
))?$/'
,
$text
,
$matches
))
{
if
(
!
preg_match
(
'/^(
[\w\.]+)(:(\w*))?(:(.*
))?$/'
,
$text
,
$matches
))
{
throw
new
InvalidConfigException
(
'The column must be specified in the format of "Attribute"
or "Attribute:Type"
'
);
throw
new
InvalidConfigException
(
'The column must be specified in the format of "Attribute"
, "Attribute:Format" or "Attribute:Format:Header
'
);
}
}
return
Yii
::
createObject
(
array
(
return
Yii
::
createObject
(
array
(
'class'
=>
DataColumn
::
className
()
,
'class'
=>
$this
->
dataColumnClass
,
'grid'
=>
$this
,
'grid'
=>
$this
,
'attribute'
=>
$matches
[
1
],
'attribute'
=>
$matches
[
1
],
'type'
=>
isset
(
$matches
[
3
])
?
$matches
[
3
]
:
'text'
,
'format'
=>
isset
(
$matches
[
3
])
?
$matches
[
3
]
:
'text'
,
'header'
=>
isset
(
$matches
[
5
])
?
$matches
[
5
]
:
null
,
));
));
}
}
...
...
framework/yii/widgets/grid/DataColumn.php
View file @
1398de3f
...
@@ -22,7 +22,7 @@ class DataColumn extends Column
...
@@ -22,7 +22,7 @@ class DataColumn extends Column
{
{
public
$attribute
;
public
$attribute
;
public
$value
;
public
$value
;
public
$
type
;
public
$
format
;
/**
/**
* @var boolean whether to allow sorting by this column. If true and [[attribute]] is found in
* @var boolean whether to allow sorting by this column. If true and [[attribute]] is found in
* the sort definition of [[GridView::dataProvider]], then the header cell of this column
* the sort definition of [[GridView::dataProvider]], then the header cell of this column
...
@@ -90,6 +90,6 @@ class DataColumn extends Column
...
@@ -90,6 +90,6 @@ class DataColumn extends Column
}
else
{
}
else
{
return
parent
::
renderDataCellContent
(
$item
,
$index
);
return
parent
::
renderDataCellContent
(
$item
,
$index
);
}
}
return
$this
->
grid
->
formatter
->
format
(
$value
,
$this
->
type
);
return
$this
->
grid
->
formatter
->
format
(
$value
,
$this
->
format
);
}
}
}
}
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