Created
August 3, 2010 16:18
-
-
Save v6ak/506664 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Representation of enumerated grid column. | |
* | |
* @author Vít Šesták 'v6ak' | |
* @copyright Copyright (c) 2010 Vít Šesták | |
* @license New BSD License | |
* @package Nette\Extras\DataGrid | |
*/ | |
class EnumColumn extends DataGridColumn{ | |
/** @var array array(value=>label) */ | |
private $values; | |
/** | |
* Enum column constructor | |
* @param string textual caption of this column | |
* @param array array(enumValue=>label) | |
*/ | |
public function __construct($caption, $values){ | |
parent::__construct($caption); | |
$this->values = $values; | |
} | |
public function formatContent($value, $data = NULL){ | |
return htmlspecialchars($this->values[$value]); | |
} | |
public function applyFilter($value){ | |
if (!$this->hasFilter()){ | |
return; | |
}; | |
$column = $this->getName(); | |
$this->getDataGrid(true)->dataSource->where('%and', array(array("[$column] = %s", $value))); | |
} | |
/** | |
* Adds selectbox filter using $values from constructor. | |
* @return IDataGridColumnFilter | |
*/ | |
public function addDefaultSelectboxFilter(){ | |
return $this->addSelectboxFilter($this->values); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment