RS
Difuculdade em carregar grid com array
Olá,
Estou tentando carregar uma grid com dados retornado de um array, mas sem sucesso.
Alguém pode me ajudar?
Classe de teste
Estou tentando carregar uma grid com dados retornado de um array, mas sem sucesso.
Alguém pode me ajudar?
- <?php
- // outros
- class ApplicationTranslator
- {
- //adiciopnei este método para retornar o array contendo os itens no seu rerspectivo idioma
- public function getMessages()
- {
- return $this->messages;
- }
- }
- ?>
Classe de teste
- <?php
- class CommonPage extends TPage
- {
- private $form, $datagrid, $pageNavigation, $loaded;
- public function __construct()
- {
- parent::__construct();
- // creates one datagrid
- $this->datagrid = new BootstrapDatagridWrapper(new TDataGrid);
- $this->datagrid->width = '100%';
- // add the columns
- $this->datagrid->addColumn( new TDataGridColumn('en','Inglês', 'left', '') );
- $this->datagrid->addColumn( new TDataGridColumn('pt','Portugês', 'left', '') );
- $this->datagrid->addColumn( new TDataGridColumn('es','Espanhol', 'left', '') );
- // creates the datagrid model
- $this->datagrid->createModel();
- $panel = new TPanelGroup( _t('Table') );
- //$panel->addHeaderWidget($input_search);
- $panel->add($this->datagrid)->style = 'overflow-x:auto';
- $panel->addFooter('footer');
- // wrap the page content using vertical box
- $vbox = new TVBox;
- $vbox->style = 'width: 100%';
- $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
- $vbox->add($panel);
- parent::add($vbox);
- }
- /**
- * Load the data into the datagrid
- */
- function onReload($param = NULL)
- {
- try
- {
- $file = ApplicationTranslator::getInstance();
- $languages = $file->getMessages();
- $limit = 10;
- $this->datagrid->clear();
- if ($languages)
- {
- foreach ($languages as $key => $values)
- {
- $item = new stdClass();
- $item->en = $languages['en'];
- //echo $value;
- $this->datagrid->addItem($item);
- /*
- * objetivo é carregar desta forma
- * $item->en = value->en;
- * $item->pt = value->pt;
- * $item->es = value->es;
- */
- }
- }
- $this->loaded = true;
- //echo '<pre>';print_r($count);echo '<pre>';
- }
- catch (Exception $e)
- {
- echo $e->getFile().' : '.$e->getLine(). "#" . $e->getMessage();
- }
- }
- function show()
- {
- // check if the datagrid is already loaded
- if (!$this->loaded)
- {
- $this->onReload( func_get_arg(0) );
- }
- parent::show();
- }
- }
- ?>
Tente o seguinte: