Skip to content

Commit

Permalink
Fix #22: Add property enableFormatter to enable/disable yii grid fo…
Browse files Browse the repository at this point in the history
…rmatter
  • Loading branch information
kartik-v committed Dec 26, 2014
1 parent dac3d3d commit 9a3f2a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ version 1.1.0
- (bug #16): Prevent default on menu item click when showConfirmAlert is set to false.
- (bug #19): Correct rendering of menu when format config is disabled.
- (bug #21): Set correct reference to `ActiveDataProvider` and `ActiveQueryInterface`.
- (enh #22): Add property `enableFormatter` to enable/disable yii grid formatter.

version 1.0.0
=============
Expand Down
11 changes: 10 additions & 1 deletion ExportMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ class ExportMenu extends GridView
*/
public $showConfirmAlert = true;

/**
* @var bool whether to enable the yii gridview formatter component.
* Defaults to `true`. If set to `false`, this will render content
* as `raw` format.
*/
public $enableFormatter = true;


/**
* @var bool whether to render the export menu as bootstrap button dropdown
* widget. Defaults to `true`. If set to `false`, this will generate a simple
Expand Down Expand Up @@ -711,8 +719,9 @@ public function generateRow($model, $key, $index)
} elseif ($column instanceof \yii\grid\ActionColumn) {
$value = '';
} else {
$format = $this->enableFormatter ? $column->format : 'raw';
$value = ($column->content === null) ?
$this->formatter->format($column->getDataCellValue($model, $key, $index), $column->format) :
$this->formatter->format($column->getDataCellValue($model, $key, $index), $format) :
call_user_func($column->content, $model, $key, $index, $column);
}
if (empty($value) && !empty($column->attribute) && $column->attribute !== null) {
Expand Down

0 comments on commit 9a3f2a9

Please sign in to comment.