Lançado Adianti Framework 7.6!
Clique aqui para saber mais
erros list fui listar um forncedor e me de o seruinte erro, mesmo usando o metodo _toString retornando o neme o erro continua controller ...
PD
erros list  
Fechado
fui listar um forncedor e me de o seruinte erro,
mesmo usando o metodo _toString retornando o neme o erro continua

controller

  1. <?php
  2. /**
  3.  * ProdutoList Listing
  4.  * @author  <your name here>
  5.  */
  6. class ProdutoList extends TStandardList
  7. {
  8.     protected $form;     // registration form
  9.     protected $datagrid// listing
  10.     protected $pageNavigation;
  11.     
  12.     /**
  13.      * Class constructor
  14.      * Creates the page, the form and the listing
  15.      */
  16.     public function __construct()
  17.     {
  18.         parent::__construct();
  19.         
  20.         // defines the database
  21.         parent::setDatabase('sample');
  22.         
  23.         // defines the active record
  24.         parent::setActiveRecord('Produto');
  25.         
  26.         // defines the filter field
  27.         parent::setFilterField('nome');
  28.         
  29.         // creates the form
  30.         $this->form = new TForm('form_search_Produto');
  31.         
  32.         // creates a table
  33.         $table = new TTable;
  34.         
  35.         // add the table inside the form
  36.         $this->form->add($table);
  37.         
  38.         // create the form fields
  39.         $filter = new TEntry('nome');
  40.         $filter->setValue(TSession::getValue('Produto_nome'));
  41.         
  42.         // add a row for the filter field
  43.         $row=$table->addRow();
  44.         $row->addCell(new TLabel('nome:'));
  45.         $row->addCell($filter);
  46.         
  47.         // create two action buttons to the form
  48.         $find_button = new TButton('find');
  49.         $new_button  = new TButton('new');
  50.         // define the button actions
  51.         $find_button->setAction(new TAction(array($this'onSearch')), _t('Find'));
  52.         $find_button->setImage('ico_find.png');
  53.         
  54.         $new_button->setAction(new TAction(array('ProdutoForm''onEdit')), _t('New'));
  55.         $new_button->setImage('ico_new.png');
  56.         
  57.         // add a row for the form actions
  58.         $row=$table->addRow();
  59.         $row->addCell($find_button);
  60.         $row->addCell($new_button);
  61.         
  62.         // define wich are the form fields
  63.         $this->form->setFields(array($filter$find_button$new_button));
  64.         
  65.         // creates a DataGrid
  66.         $this->datagrid = new TQuickGrid;
  67.         $this->datagrid->setHeight(320);
  68.         
  69.         // creates the datagrid columns
  70.         767 $this->datagrid->addQuickColumn('id''id''right'100);
  71.         $nome $this->datagrid->addQuickColumn('nome''nome''left'200);
  72.         $descricao $this->datagrid->addQuickColumn('descricao''descricao''left'200);
  73.         $preco $this->datagrid->addQuickColumn('preco''preco''left'200);
  74.         $fornecedor_id $this->datagrid->addQuickColumn('fornecedor''fornecedor''right'100);
  75.         
  76.         // add the actions to the datagrid
  77.         $this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array('ProdutoForm''onEdit')), 'id''ico_edit.png');
  78.         $this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this'onDelete')), 'id''ico_delete.png');
  79.         
  80.         // create the datagrid model
  81.         $this->datagrid->createModel();
  82.         
  83.         // creates the page navigation
  84.         $this->pageNavigation = new TPageNavigation;
  85.         $this->pageNavigation->setAction(new TAction(array($this'onReload')));
  86.         $this->pageNavigation->setWidth($this->datagrid->getWidth());
  87.         
  88.         // creates the page structure using a table
  89.         $table = new TTable;
  90.         $table->addRow()->addCell($this->form);
  91.         $table->addRow()->addCell($this->datagrid);
  92.         $table->addRow()->addCell($this->pageNavigation);
  93.         // add the table inside the page
  94.         parent::add($table);
  95.     }
  96. }
  97. ?>



fornecedor

  1. <?php
  2. /**
  3.  * Fornecedor Active Record
  4.  * @author  <your-name-here>
  5.  */
  6. class Fornecedor extends TRecord
  7. {
  8.     const TABLENAME 'tblFornecedor';
  9.     const PRIMARYKEY'id';
  10.     const IDPOLICY =  'max'// {max, serial}
  11.     
  12.     
  13.     /**
  14.      * Constructor method
  15.      */
  16.     public function __construct(767 NULL)
  17.     {
  18.         parent::__construct(767);
  19.         parent::addAttribute('razaoSocial');
  20.         parent::addAttribute('cnpj');
  21.         parent::addAttribute('responsavel');
  22.         parent::addAttribute('telefone');
  23.         parent::addAttribute('cep');
  24.         parent::addAttribute('rua');
  25.         parent::addAttribute('bairro');
  26.         parent::addAttribute('cidade');
  27.         parent::addAttribute('uf');
  28.         parent::addAttribute('numero');
  29.     }
  30. public function __toString(){
  31. return $this->razaoSocial;
  32. }
  33. }
  34. ?>



Pacotão Dominando o Adianti Framework 7
O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado! Versão 7.4


Dominando o Adianti 7 Quero me inscrever agora!

Comentários (1)


PD

Oi Alexandre,

Você mandou listar da classe Produto, o atributo Fornecedor, que é um objeto TRecord. Somente componentes (classes que implementam IWidget), podem ser acrescentadas na datagrid. Se você quiser exibir o nome do fornecedor, use na datagrid "fornecedor_nome" e crie um método get_fornecedor_nome().

PS: Na próxima versão, você poderá usar na datagrid "fornecedor->nome". O que ficará bem melhor.

abraços,
Pablo