Skip to content

Commit

Permalink
Merge pull request #189 from ThaDafinser/hotfix/defaultValueSelect
Browse files Browse the repository at this point in the history
bugfix jqgrid default select option
  • Loading branch information
ThaDafinser committed Jul 16, 2015
2 parents 0db898a + 1280708 commit cc82443
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/ZfcDatagrid/Column/Formatter/HtmlTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function getRowIdPlaceholder()
}

/**
* @param AbstractColumn $col
* @param AbstractColumn $col
* @return string
*/
public function getFormattedValue(AbstractColumn $col)
Expand Down
14 changes: 7 additions & 7 deletions src/ZfcDatagrid/Column/Style/Align.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,36 @@ class Align extends AbstractStyle
* @var string
*/
public static $LEFT = 'left';

/**
*
* @var string
*/
public static $RIGHT = 'right';

/**
*
* @var string
*/
public static $CENTER = 'center';

/**
*
* @var string
*/
public static $JUSTIFY= 'justify';
public static $JUSTIFY = 'justify';

/**
*
* @var string
*/
protected $alignment;

public function __construct($alignment = self::LEFT)
{
$this->setAlignment($alignment);
}

/**
*
* @param string $alignment
Expand Down
1 change: 0 additions & 1 deletion src/ZfcDatagrid/Column/Style/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* general or based on a value
*
*/

namespace ZfcDatagrid\Column\Style;

class Color extends AbstractColor
Expand Down
1 change: 0 additions & 1 deletion src/ZfcDatagrid/Column/Type/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/**
* Image type
*/

namespace ZfcDatagrid\Column\Type;

use InvalidArgumentException;
Expand Down
1 change: 0 additions & 1 deletion src/ZfcDatagrid/DataSource/Doctrine2/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* or if we use the "safe" variant by Doctrine2
*
*/

namespace ZfcDatagrid\DataSource\Doctrine2;

use Doctrine\ORM\QueryBuilder;
Expand Down
1 change: 0 additions & 1 deletion src/ZfcDatagrid/Renderer/AbstractExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Methods which can be used in (all) export renderer
*
*/

namespace ZfcDatagrid\Renderer;

use ZfcDatagrid\Column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ public function __invoke($row, array $cols, AbstractAction $rowClickAction = nul
$cssStyles[] = 'background-color: #' . $style->getRgbHexString();
break;
case 'ZfcDatagrid\Column\Style\Align':
$cssStyles[] = 'text-align: '.$style->getAlignment();
$cssStyles[] = 'text-align: ' . $style->getAlignment();
break;
case 'ZfcDatagrid\Column\Style\Strikethrough':
$value = '<s>'.$value.'</s>';
$value = '<s>' . $value . '</s>';
break;
default:
throw new \InvalidArgumentException('Not defined style: "' . get_class($style) . '"');
Expand Down
1 change: 0 additions & 1 deletion src/ZfcDatagrid/Renderer/Csv/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Render datagrid as CSV
*
*/

namespace ZfcDatagrid\Renderer\Csv;

use Zend\Http\Headers;
Expand Down
18 changes: 11 additions & 7 deletions src/ZfcDatagrid/Renderer/JqGrid/View/Helper/Columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function __invoke(array $columns)
'search' => (bool) $column->isUserFilterEnabled(),
];

/**
/*
* Formatting
*/
$formatter = $this->getFormatter($column);
Expand All @@ -107,25 +107,29 @@ public function __invoke(array $columns)
$options['align'] = (string) 'right';
}

/**
/*
* Cellattr
*/
$rendererParameters = $column->getRendererParameters('jqGrid');
if (isset($rendererParameters['cellattr'])) {
$options['cellattr'] = (string) $rendererParameters['cellattr'];
}

/**
/*
* Filtering
*/
$searchoptions = [];
$searchoptions['clearSearch'] = false;
if ($column->hasFilterSelectOptions() === true) {
$options['stype'] = 'select';
$searchoptions['value'] = $column->getFilterSelectOptions();
}

if ($column->hasFilterDefaultValue() === true) {
if ($column->hasFilterDefaultValue() === true) {
$searchoptions['defaultValue'] = $column->getFilterDefaultValue();
} else {
$searchoptions['defaultValue'] = '';
}
} elseif ($column->hasFilterDefaultValue() === true) {
$filter = new \ZfcDatagrid\Filter();
$filter->setFromColumn($column, $column->getFilterDefaultValue());

Expand Down Expand Up @@ -274,9 +278,9 @@ private function getStyles(Column\AbstractColumn $col)
// do NOTHING! this is done by loadComplete event...
// At this stage jqgrid haven't created the columns...
break;

case 'ZfcDatagrid\Column\Style\Align':
$styleString = 'cellvalue = \'<span style="text-align: '.$style->getAlignment().';">\' + cellvalue + \'</span>\';';
$styleString = 'cellvalue = \'<span style="text-align: ' . $style->getAlignment() . ';">\' + cellvalue + \'</span>\';';
break;

default:
Expand Down
9 changes: 4 additions & 5 deletions src/ZfcDatagrid/Renderer/PHPExcel/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
/**
* Output as an excel file
*/

namespace ZfcDatagrid\Renderer\PHPExcel;

use PHPExcel;
use PHPExcel_Cell;
use PHPExcel_Cell_DataType;
use PHPExcel_Style_Alignment;
use PHPExcel_Style_Border;
use PHPExcel_Style_Color;
use PHPExcel_Style_Fill;
use PHPExcel_Worksheet_PageSetup;
use PHPExcel_Style_Alignment;
use Zend\Http\Headers;
use Zend\Http\Response\Stream as ResponseStream;
use ZfcDatagrid\Renderer\AbstractExport;
Expand Down Expand Up @@ -123,7 +122,7 @@ public function execute()
],
]);
break;

case 'ZfcDatagrid\Column\Style\Align':
switch ($style->getAlignment()) {
case \ZfcDatagrid\Column\Style\Align::$RIGHT:
Expand All @@ -142,9 +141,9 @@ public function execute()
//throw new \Exception('Not defined yet: "'.get_class($style->getAlignment()).'"');
break;
}

break;

case 'ZfcDatagrid\Column\Style\Strikethrough':
$columnStyle->getFont()->setStrikethrough(true);
break;
Expand Down
31 changes: 15 additions & 16 deletions src/ZfcDatagrid/Renderer/TCPDF/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/**
* Output as a PDF file
*/

namespace ZfcDatagrid\Renderer\TCPDF;

use TCPDF;
Expand All @@ -26,7 +25,7 @@ class Renderer extends AbstractExport
* @var TCPDF
*/
protected $pdf;

/**
*
* @var Alignment
Expand Down Expand Up @@ -331,43 +330,43 @@ protected function printTableRow(array $row, $rowHeight)
if (is_array($text)) {
$text = implode(PHP_EOL, $text);
}

/*
* Styles
*/
$this->setFontData();

$isHtml = false;
$isHtml = false;
$backgroundColor = false;

$styles = array_merge($this->getRowStyles(), $col->getStyles());
foreach ($styles as $style) {
/* @var $style \ZfcDatagrid\Column\Style\AbstractStyle */
if ($style->isApply($row) === true) {
switch (get_class($style)) {

case 'ZfcDatagrid\Column\Style\Bold':
$this->setBold();
break;

case 'ZfcDatagrid\Column\Style\Italic':
$this->setItalic();
break;

case 'ZfcDatagrid\Column\Style\Color':
$this->setColor($style->getRgbArray());
break;

case 'ZfcDatagrid\Column\Style\BackgroundColor':
$this->setBackgroundColor($style->getRgbArray());
$backgroundColor = true;
break;

case 'ZfcDatagrid\Column\Style\Strikethrough':
$text = '<del>' . $text . '</del>';
$text = '<del>' . $text . '</del>';
$isHtml = true;
break;

case 'ZfcDatagrid\Column\Style\Align':
switch ($style->getAlignment()) {
case \ZfcDatagrid\Column\Style\Align::$RIGHT:
Expand All @@ -387,14 +386,14 @@ protected function printTableRow(array $row, $rowHeight)
break;
}
break;

default:
throw new \Exception('Not defined yet: "' . get_class($style) . '"');
break;
}
}
}

// MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0, $valign='T', $fitcell=false)
$pdf->MultiCell($col->getWidth(), $rowHeight, $text, 1, $this->getTextAlignment(), $backgroundColor, 1, $x, $y, true, 0, $isHtml);
}
Expand Down Expand Up @@ -494,7 +493,7 @@ protected function setBackgroundColor(array $rgb)
$pdf = $this->getPdf();
$pdf->SetFillColor($rgb['red'], $rgb['green'], $rgb['blue']);
}

/**
*
* @param string $alignment
Expand All @@ -503,7 +502,7 @@ public function setTextAlignment($alignment)
{
$this->alignment = $alignment;
}

/**
*
* @return string
Expand Down
4 changes: 2 additions & 2 deletions tests/ZfcDatagridTest/Column/Style/AbstractStyleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ public function testStyleByColumn()

// Test lower value
$row = [
$this->column->getUniqueId() => 5,
$this->column->getUniqueId() => 5,
$columnCompare->getUniqueId() => 15,
];
$this->assertFalse($style->isApply($row));

// Test greater value
$row = [
$this->column->getUniqueId() => 15,
$this->column->getUniqueId() => 15,
$columnCompare->getUniqueId() => 10,
];
$this->assertTrue($style->isApply($row));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace ZfcDatagridTest\DataSource\Doctrine2\Mocks;

/**
Expand Down

0 comments on commit cc82443

Please sign in to comment.