Skip to content

Commit

Permalink
Merge pull request #79 from alessandropietrobelli/master
Browse files Browse the repository at this point in the history
Filter Select (with int index array options)
  • Loading branch information
ThaDafinser committed Mar 24, 2014
2 parents aef3d7a + 7529c67 commit cfeddec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/ZfcDatagrid/Column/AbstractColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,14 @@ public function getFilterDefaultOperation()
*/
public function setFilterSelectOptions(array $options = null, $noSelect = true)
{
// This work also with options with integer based array index such as
// array(0 => 'zero', 1 => 'once', 2 => 'double', 3 => 'triple'....)

if ($noSelect === true) {
$nothing = array(
'' => '-'
);
$options = array_merge($nothing, $options);
$options[''] = '-';
$this->setFilterDefaultValue('');
}

$this->filterSelectOptions = $options;
}

Expand Down
2 changes: 2 additions & 0 deletions view/zfc-datagrid/renderer/bootstrapTable/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ if($this->rowClickAction !== null){
foreach ($column->getFilterSelectOptions() as $value => $option) {
if ($column->getFilterActiveValue() == sprintf($column->getFilterDefaultOperation(), $value)) {
$htmlFilter .= '<option value="' . $value . '" selected="selected">' . $option . '</option>';
} else if (($column->getFilterActiveValue() == '') && ($value == '')){
$htmlFilter .= '<option value="' . $value . '" selected="selected">' . $option . '</option>';
} else {
$htmlFilter .= '<option value="' . $value . '">' . $option . '</option>';
}
Expand Down

0 comments on commit cfeddec

Please sign in to comment.