/** * Add action to the datagrid * @param $label Action Label * @param $action TAction Object * @param $icon Action Icon */ public function addQuickAction($label, TDataGridAction $action, $field, $icon = 'ico_save.png') { $action->setLabel($label); $action->setImage($icon); $action->setField($field); // add the datagrid action parent::addAction($action); }
/** * */ 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; }
// adiciona as colunas à DataGrid $datagrid->addColumn($codigo); $datagrid->addColumn($nome); $datagrid->addColumn($endereco); $datagrid->addColumn($telefone); // instancia duas ações da DataGrid $action1 = new TDataGridAction('onDelete'); $action1->setLabel('Deletar'); $action1->setImage('ico_delete.png'); $action1->setField('codigo'); $action2 = new TDataGridAction('onView'); $action2->setLabel('Visualizar'); $action2->setImage('ico_view.png'); $action2->setField('nome'); // adiciona as ações à DataGrid $datagrid->addAction($action1); $datagrid->addAction($action2); // cria o modelo da DataGrid, montando sua estrutura $datagrid->createModel(); // adiciona um objeto padrão à DataGrid $item = new StdClass(); $item->codigo = '1'; $item->nome = 'Daline DallOglio'; $item->endereco = 'Rua Conceição'; $item->fone = '1111-1111'; $datagrid->addItem($item); // adiciona um objeto padrão à DataGrid $item = new StdClass(); $item->codigo = '2'; $item->nome = 'William Scatola'; $item->endereco = 'Rua Conceição';