-
-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
180 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
@@ -147,6 +147,99 @@ protected function checkValidFilters() | |
} | ||
} | ||
|
||
/** | ||
* Gets Default Excel Cell Format | ||
* | ||
* @return string | ||
*/ | ||
public function getDefaultExcelFormat() | ||
{ | ||
if (!isset($this->format)) { | ||
return ''; | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Parses Excel Cell Formats for export | ||
* | ||
* @return string | ||
*/ | ||
public function parseExcelFormats(&$options, $model, $key, $index) | ||
{ | ||
$autoFormat = $this->grid->autoXlFormat; | ||
if (!isset($this->xlsFormat) && !$autoFormat) { | ||
return; | ||
} | ||
$fmt = ''; | ||
$format = is_array($this->format) ? $this->format[0] : $this->format; | ||
$formatter = $this->grid->formatter; | ||
if (isset($this->xlFormat)) { | ||
$fmt = $this->xlFormat; | ||
} elseif ($autoFormat && isset($this->format)) { | ||
$tSep = isset($formatter->thousandSeparator) ? $formatter->thousandSeparator : ','; | ||
$dSep = isset($formatter->decimalSeparator) ? $formatter->decimalSeparator : '.'; | ||
switch ($format) { | ||
case 'text': | ||
case 'html': | ||
case 'raw': | ||
case 'ntext': | ||
case 'paragraphs': | ||
case 'spellout': | ||
case 'boolean': | ||
case 'relativeTime': | ||
$fmt = '\@'; | ||
break; | ||
case 'integer': | ||
$fmt = "\\#\\{$tSep}\\#\\#0"; | ||
break; | ||
case 'decimal': | ||
case 'percent': | ||
case 'scientific': | ||
$decimals = is_array($this->format) && isset($this->format[1]) ? $this->format[1] : 2; | ||
$append = $decimals > 0 ? "\\{$dSep}" . str_repeat('0', $decimals) : ''; | ||
if ($format == 'percent') { | ||
$append .= '%'; | ||
} | ||
$fmt = ($format == 'scientific') ? "0{$append}E+00" : "\\#\\{$tSep}\\#\\#0" . $append; | ||
break; | ||
case 'currency': | ||
$curr = is_array($this->format) && isset($this->format[1]) ? $this->format[1] : | ||
isset($formatter->currencyCode) ? $formatter->currencyCode . ' ' : ''; | ||
$fmt = "{$curr}\\#\\{$tSep}\\#\\#0{$dSep}00"; | ||
break; | ||
case 'date': | ||
case 'time': | ||
$fmt = 'Short ' . ucfirst($format); | ||
break; | ||
case 'datetime': | ||
$fmt = 'yyyy\-MM\-dd HH\:mm\:ss'; | ||
break; | ||
default: | ||
$fmt = ''; | ||
break; | ||
} | ||
} | ||
if ($format === 'date' || $format === 'datetime' || $format === 'time') { | ||
$rawValue = $this->getDataCellValue($model, $key, $index); | ||
switch ($format) { | ||
case 'date': | ||
$rawVal = $formatter->format($rawValue, ['date', 'php:Y-m-d']); | ||
break; | ||
case 'datetime': | ||
$rawVal = $formatter->format($rawValue, ['date', 'php:Y-m-d H:i:s']); | ||
break; | ||
case 'time': | ||
$rawVal = $formatter->format($rawValue, ['date', 'php:H:i:s']); | ||
break; | ||
} | ||
$options['data-raw-value'] = $rawVal; | ||
} elseif ($format === 'integer' || $format === 'decimal' || $format === 'percent' || $format === 'scientific') { | ||
$options['data-raw-value'] = $this->getDataCellValue($model, $key, $index); | ||
} | ||
Html::addCssStyle($options, ['mso-number-format' => '"' . $fmt . '"']); | ||
} | ||
|
||
/** | ||
* Checks `hidden` property and hides the column from display | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
@@ -280,6 +280,12 @@ class DataColumn extends \yii\grid\DataColumn | |
* - `options`: array, HTML attributes for the group footer row. | ||
*/ | ||
public $groupFooter = []; | ||
|
||
/** | ||
* @var string the cell format for EXCEL exported content. | ||
* @see http://cosicimiento.blogspot.in/2008/11/styling-excel-cells-with-mso-number.html | ||
*/ | ||
public $xlFormat; | ||
|
||
/** | ||
* @var array of row data for the column for the current page | ||
|
@@ -324,6 +330,7 @@ public function renderDataCell($model, $key, $index) | |
{ | ||
$options = $this->fetchContentOptions($model, $key, $index); | ||
$this->parseGrouping($options, $model, $key, $index); | ||
$this->parseExcelFormats($options, $model, $key, $index); | ||
$this->initPjax($this->_clientScript); | ||
return Html::tag('td', $this->renderDataCellContent($model, $key, $index), $options); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
@@ -611,6 +611,13 @@ class GridView extends \yii\grid\GridView | |
*/ | ||
public $exportConversions = []; | ||
|
||
/** | ||
* @var boolean, applicable for EXCEL export content only. This determines whether the exported EXCEL cell data | ||
* will be automatically guessed and formatted based on `DataColumn::format` property. You can override this | ||
* behavior and change the auto-derived format mask by setting `DataColumn::xlFormat`. | ||
*/ | ||
public $autoXlFormat = false; | ||
|
||
/** | ||
* @var array|boolean the HTML attributes for the grid container. The grid table items | ||
* will be wrapped in a `div` container with the configured HTML attributes. The ID for | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
*/ | ||
|
||
namespace kartik\grid; | ||
|
@@ -98,6 +98,20 @@ class SerialColumn extends \yii\grid\SerialColumn | |
*/ | ||
public $mergeHeader = true; | ||
|
||
/** | ||
* @var string|array in which format should the value of each data model be displayed as (e.g. `"raw"`, `"text"`, `"html"`, | ||
* `['date', 'php:Y-m-d']`). Supported formats are determined by the [[GridView::formatter|formatter]] used by | ||
* the [[GridView]]. Default format is "text" which will format the value as an HTML-encoded plain text when | ||
* [[\yii\i18n\Formatter]] is used as the [[GridView::$formatter|formatter]] of the GridView. | ||
*/ | ||
public $format = 'text'; | ||
|
||
/** | ||
* @var string the cell format for EXCEL exported content. | ||
* @see http://cosicimiento.blogspot.in/2008/11/styling-excel-cells-with-mso-number.html | ||
*/ | ||
public $xlFormat; | ||
|
||
/** | ||
* @var array of row data for the column for the current page | ||
*/ | ||
|
@@ -120,6 +134,8 @@ public function init() | |
public function renderDataCell($model, $key, $index) | ||
{ | ||
$options = $this->fetchContentOptions($model, $key, $index); | ||
return Html::tag('td', $this->renderDataCellContent($model, $key, $index), $options); | ||
$this->parseExcelFormats($options, $model, $key, $index); | ||
$out = $this->grid->formatter->format($this->renderDataCellContent($model, $key, $index), $this->format); | ||
return Html::tag('td', $out, $options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @package yii2-grid | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
* | ||
* Gridview ExpandRowColumn styling and enhancements | ||
* Built for Yii Framework 2.0 | ||
|
Oops, something went wrong.