Source for file TDataGridColumn.php
Documentation is available at TDataGridColumn.php
namespace
Adianti \
Widget \
Datagrid ;
use
Adianti \
Widget \
Form \
TEntry ;
* Representes a DataGrid column
* @author Pablo Dall'Oglio
* @copyright Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
* @license http://www.adianti.com.br/framework-license
private $totalTransformed ;
* @param $name = Name of the column in the database
* @param $label = Text label that will be shown in the header
* @param $align = Column align (left, center, right)
* @param $width = Column Width (pixels)
public function __construct ( $name , $label , $align , $width =
NULL )
$this -> searchable =
false ;
$this -> properties =
array ( ) ;
$this -> dataProperties =
array ( ) ;
* Define column visibility
* Enable column auto hide
$this -> searchable =
true ;
$name =
'search_' .
str_replace ( [ '-' , '>' ] , [ '_' , '' ] , $this -> name ) ;
$this -> inputSearch =
new TEntry ( $name ) ;
$this -> inputSearch -> setId ( $name ) ;
$this -> inputSearch -> { 'placeholder' } =
AdiantiCoreTranslator :: translate ( 'Search' ) ;
$this -> inputSearch -> setSize ( '50%' ) ;
return $this -> inputSearch ;
* Returns if column is searchable
return $this -> searchable ;
* Define a column header property
* @param $name Property Name
* @param $value Property Value
$this -> properties [ $name ] =
$value ;
* @param $name Property Name
* @param $value Property Value
$this -> dataProperties [ $name ] =
$value ;
* Return a column property
* @param $name Property Name
if ( isset
( $this -> properties [ $name ] ))
return $this -> properties [ $name ] ;
* @param $name Property Name
if ( isset
( $this -> dataProperties [ $name ] ))
return $this -> dataProperties [ $name ] ;
* Return column properties
return $this -> properties ;
return $this -> dataProperties ;
* Intercepts whenever someones assign a new property's value
* @param $name Property Name
* @param $value Property Value
public function __set ( $name , $value )
// objects and arrays are not set as properties
// store the property's value
* Returns the database column's name
* Returns the column's label
* @param $label column label
* Returns the column's align
* Returns the column's width
* Define the action to be executed when
* the user clicks over the column header
* @param $action TAction object
* @param $parameters Action parameters
public function setAction ( TAction $action , $parameters =
null )
$this -> action -> setParameters ( $parameters ) ;
* Returns the action defined by set_action() method
* @return the action to be executed when the
* user clicks over the column header
// verify if the column has an actions
* Define the action to be executed when
* the user clicks do edit the column
* @param $action A TDataGridAction object
$this -> editaction =
$editaction ;
* Returns the action defined by setEditAction() method
* @return the action to be executed when the
* user clicks do edit the column
// verify if the column has an actions
return $this -> editaction ;
* Define a callback function to be applyed over the column's data
* @param $callback A function name of a method of an object
$this -> transformer =
$callback ;
* Returns the callback defined by the setTransformer()
return $this -> transformer ;
public function enableTotal ( $function , $prefix =
null , $decimals =
2 , $decimal_separator =
',' , $thousand_separator =
'.' )
$this -> totalFunction =
$function ;
$this -> totalMask =
" {
$prefix} :{$decimals } {$decimal_separator } {$thousand_separator } " ;
$totalCallback =
function ( $values ) {
* Define a callback function to totalize column
* @param $callback A function name of a method of an object
* @param $apply_transformer Apply transform function also in total
$this -> totalCallback =
$callback ;
* Returns the callback defined by the setTotalFunction()
return $this -> totalCallback ;
return $this -> totalFunction ;