/** * Add a column * @param $label Field Label * @param $object Field Object * @param $size Field Size */ public function addQuickColumn($label, $name, $align = 'left', $size = 200, TAction $action = NULL, $param = NULL) { // creates a new column $object = new TDataGridColumn($name, $label, $align, $size); if ($action instanceof TAction) { // create ordering $action->setParameter($param[0], $param[1]); $object->setAction($action); } // add the column to the datagrid parent::addColumn($object); return $object; }
/** * */ public function makeTDataGrid($properties) { $table = new TTable(); $widget = new TDataGrid(); $widget->setHeight((string) $properties->{'height'}); if ($properties->{'columns'}) { foreach ($properties->{'columns'} as $Column) { $dgcolumn = new TDataGridColumn((string) $Column->{'name'}, (string) $Column->{'label'}, (string) $Column->{'align'}, (string) $Column->{'width'}); $widget->addColumn($dgcolumn); $this->fieldsByName[(string) $Column->{'name'}] = $dgcolumn; } } if ($properties->{'actions'}) { foreach ($properties->{'actions'} as $Action) { $dgaction = new TDataGridAction(array($this->controller, (string) $Action->{'method'})); $dgaction->setLabel((string) $Action->{'label'}); $dgaction->setImage((string) $Action->{'image'}); $dgaction->setField((string) $Action->{'field'}); $widget->addAction($dgaction); //$this->fieldsByName[(string)$properties->Name] = $column; } } if ((string) $properties->{'pagenavigator'} == 'yes') { $loader = (string) $properties->{'loader'} ? (string) $properties->{'loader'} : 'onReload'; $pageNavigation = new TPageNavigation(); $pageNavigation->setAction(new TAction(array($this->controller, $loader))); $pageNavigation->setWidth($widget->getWidth()); } $widget->createModel(); $row = $table->addRow(); $row->addCell($widget); if (isset($pageNavigation)) { $row = $table->addRow(); $row->addCell($pageNavigation); $widget->setPageNavigation($pageNavigation); } $this->fieldsByName[(string) $properties->{'name'}] = $widget; $widget = $table; return $widget; }