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 ...
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?
 
  1. <?php
  2. // outros
  3. class ApplicationTranslator
  4. {
  5. //adiciopnei este método para retornar o array contendo os itens no seu rerspectivo idioma
  6. public function getMessages()
  7. {
  8. return $this->messages;
  9. }
  10. }
  11. ?>


Classe de teste
 
  1. <?php
  2. class CommonPage extends TPage
  3. {
  4. private $form, $datagrid, $pageNavigation, $loaded;
  5. public function __construct()
  6. {
  7. parent::__construct();
  8. // creates one datagrid
  9. $this->datagrid = new BootstrapDatagridWrapper(new TDataGrid);
  10. $this->datagrid->width = '100%';
  11. // add the columns
  12. $this->datagrid->addColumn( new TDataGridColumn('en','Inglês', 'left', '') );
  13. $this->datagrid->addColumn( new TDataGridColumn('pt','Portugês', 'left', '') );
  14. $this->datagrid->addColumn( new TDataGridColumn('es','Espanhol', 'left', '') );
  15. // creates the datagrid model
  16. $this->datagrid->createModel();
  17. $panel = new TPanelGroup( _t('Table') );
  18. //$panel->addHeaderWidget($input_search);
  19. $panel->add($this->datagrid)->style = 'overflow-x:auto';
  20. $panel->addFooter('footer');
  21. // wrap the page content using vertical box
  22. $vbox = new TVBox;
  23. $vbox->style = 'width: 100%';
  24. $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  25. $vbox->add($panel);
  26. parent::add($vbox);
  27. }
  28. /**
  29. * Load the data into the datagrid
  30. */
  31. function onReload($param = NULL)
  32. {
  33. try
  34. {
  35. $file = ApplicationTranslator::getInstance();
  36. $languages = $file->getMessages();
  37. $limit = 10;
  38. $this->datagrid->clear();
  39. if ($languages)
  40. {
  41. foreach ($languages as $key => $values)
  42. {
  43. $item = new stdClass();
  44. $item->en = $languages['en'];
  45. //echo $value;
  46. $this->datagrid->addItem($item);
  47. /*
  48. * objetivo é carregar desta forma
  49. * $item->en = value->en;
  50. * $item->pt = value->pt;
  51. * $item->es = value->es;
  52. */
  53. }
  54. }
  55. $this->loaded = true;
  56. //echo '<pre>';print_r($count);echo '<pre>';
  57. }
  58. catch (Exception $e)
  59. {
  60. echo $e->getFile().' : '.$e->getLine(). "#" . $e->getMessage();
  61. }
  62. }
  63. function show()
  64. {
  65. // check if the datagrid is already loaded
  66. if (!$this->loaded)
  67. {
  68. $this->onReload( func_get_arg(0) );
  69. }
  70. parent::show();
  71. }
  72. }
  73. ?>

Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework Quero me inscrever agora!

Comentários (1)


NR

Tente o seguinte:
 
  1. <?php
  2. foreach ($languages['en'] as $key => $value)
  3. {
  4. $item = new stdClass();
  5. $item->en = $value;
  6. $item->pt = $languages['pt'][$key];
  7. $item->es = $languages['es'][$key];
  8. $this->datagrid->addItem($item);
  9. }
  10. ?>