Skip to content

Commit

Permalink
Filter Select (with int index array options)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandropietrobelli committed Mar 21, 2014
1 parent aef3d7a commit 7529c67
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 7529c67

Please sign in to comment.