Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Onde estou errando ? Mostra um Relaciomanto em Grid Estou querendo mostrar um Lista de Suporte com o nome do cliente "RAZAOSOCIAL" da forma que ta ai não mostra nada no Campo RAZAOSOCIAL VOU MANDA UM IMAGEM EM ANEXO COMO ESTA VOLTANDO. ...
PO
Onde estou errando ? Mostra um Relaciomanto em Grid  
Fechado
Estou querendo mostrar um Lista de Suporte com o nome do cliente "RAZAOSOCIAL"
da forma que ta ai não mostra nada no Campo RAZAOSOCIAL VOU MANDA UM IMAGEM EM ANEXO
COMO ESTA VOLTANDO.


  1. <?php
  2. /**
  3.  * Cliente Active Record
  4.  * @author  <your-name-here>
  5.  */
  6. class Cliente extends TRecord
  7. {
  8.     const TABLENAME 'CLIENTE';
  9.     const PRIMARYKEY'CODIGO';
  10.     const IDPOLICY =  'max'// {max, serial}
  11.     
  12.     
  13.     /**
  14.      * Constructor method
  15.      */
  16.     public function __construct(1174 NULL$callObjectLoad TRUE)
  17.     {
  18.         parent::__construct(1174$callObjectLoad);
  19.         parent::addAttribute('RAZAOSOCIAL');
  20.         parent::addAttribute('FANTASIA');
  21.         parent::addAttribute('LOGRADOURO');
  22.         parent::addAttribute('BAIRRO');
  23.         parent::addAttribute('ENDCOMPL');
  24.         parent::addAttribute('CEP');
  25.         parent::addAttribute('FONE');
  26.         parent::addAttribute('FAX');
  27.         parent::addAttribute('CNPJCPF');
  28.         parent::addAttribute('IERG');
  29.         parent::addAttribute('NOMECONTATO');
  30.         parent::addAttribute('CELCONTATO');
  31.         parent::addAttribute('DTCAD');
  32.         parent::addAttribute('EMAIL');
  33.         parent::addAttribute('ORGAOEXP');
  34.         parent::addAttribute('ENDNUM');
  35.         parent::addAttribute('CIDADE');
  36.         parent::addAttribute('RESPONSAVEL');
  37.         parent::addAttribute('DTATULIZACAO');
  38.         parent::addAttribute('LIMITE');
  39.         parent::addAttribute('RESPCOMPRA');
  40.         parent::addAttribute('FONERESPCOMPRA');
  41.         parent::addAttribute('STATUS');
  42.         parent::addAttribute('TIPO');
  43.         parent::addAttribute('CONJUGUE');
  44.         parent::addAttribute('ESTCIVIL');
  45.         parent::addAttribute('DTNASC');
  46.         parent::addAttribute('CLIENTEDESDE');
  47.         parent::addAttribute('TPPGTOAUT');
  48.         parent::addAttribute('PAI');
  49.         parent::addAttribute('MAE');
  50.         parent::addAttribute('SEXO');
  51.         parent::addAttribute('TP_NF');
  52.     }
  53. }
  1. <?php
  2. /**
  3.  * SuporteForm Registration
  4.  * @author  <your name here>
  5.  */
  6. class SuporteForm extends TStandardForm
  7. {
  8.     protected $form// form
  9.     
  10.     /**
  11.      * Class constructor
  12.      * Creates the page and the registration form
  13.      */
  14.     function __construct()
  15.     {
  16.         parent::__construct();
  17.         
  18.         parent::setDatabase('prov');              // defines the database
  19.         parent::setActiveRecord('Suporte');     // defines the active record
  20.         
  21.         // creates the form
  22.         $this->form = new TQuickForm('form_Suporte');
  23.         $this->form->class 'tform'// CSS class
  24.         $this->form->style 'width: 500px';
  25.         
  26.         // define the form title
  27.         $this->form->setFormTitle('Suporte');
  28.         
  29.         // create the form fields
  30.         $CODIGO                         = new TEntry('CODIGO');
  31.         $DATACAD                        = new TDate('DATACAD');
  32.         $CLIENTE                        = new TEntry('CLIENTE');
  33.         $STATUS                         = new TEntry('STATUS');
  34.         $FONECONTATO                    = new TEntry('FONECONTATO');
  35.         $DATARECLAMACAO                 = new TDate('DATARECLAMACAO');
  36.         $DATAPREVTERNO                  = new TDate('DATAPREVTERNO');
  37.         $HORARECLAMACAO                 = new TEntry('HORARECLAMACAO');
  38.         $HORAPREVTERNO                  = new TEntry('HORAPREVTERNO');
  39.         $PESSOAATENDIDA                 = new TEntry('PESSOAATENDIDA');
  40.         $TITULOPROBLEMA                 = new TEntry('TITULOPROBLEMA');
  41.         $DESCRICAOPROBLEMA              = new TEntry('DESCRICAOPROBLEMA');
  42.         $FUNCIONARIOATENDEU             = new TEntry('FUNCIONARIOATENDEU');
  43.         $DATABAIXA                      = new TDate('DATABAIXA');
  44.         $HORABAIXA                      = new TEntry('HORABAIXA');
  45.         $COBRANCA                       = new TEntry('COBRANCA');
  46.         $VALORCOBRADO                   = new TEntry('VALORCOBRADO');
  47.         $TPSERVICO                      = new TEntry('TPSERVICO');
  48.         $AB_TECNICO                     = new TEntry('AB_TECNICO');
  49.         $FC_TECNICO                     = new TEntry('FC_TECNICO');
  50.         $TECNICO                        = new TEntry('TECNICO');
  51.         $DT_DESPACHO                    = new TDate('DT_DESPACHO');
  52.         $HR_DESPACHO                    = new TEntry('HR_DESPACHO');
  53.         // add the fields
  54.         $this->form->addQuickField('CODIGO'$CODIGO,  100);
  55.         $this->form->addQuickField('DATACAD'$DATACAD,  100);
  56.         $this->form->addQuickField('CLIENTE'$CLIENTE,  100);
  57.         $this->form->addQuickField('STATUS'$STATUS,  200);
  58.         $this->form->addQuickField('FONECONTATO'$FONECONTATO,  200);
  59.         $this->form->addQuickField('DATARECLAMACAO'$DATARECLAMACAO,  100);
  60.         $this->form->addQuickField('DATAPREVTERNO'$DATAPREVTERNO,  100);
  61.         $this->form->addQuickField('HORARECLAMACAO'$HORARECLAMACAO,  200);
  62.         $this->form->addQuickField('HORAPREVTERNO'$HORAPREVTERNO,  200);
  63.         $this->form->addQuickField('PESSOAATENDIDA'$PESSOAATENDIDA,  200);
  64.         $this->form->addQuickField('TITULOPROBLEMA'$TITULOPROBLEMA,  200);
  65.         $this->form->addQuickField('DESCRICAOPROBLEMA'$DESCRICAOPROBLEMA,  200);
  66.         $this->form->addQuickField('FUNCIONARIOATENDEU'$FUNCIONARIOATENDEU,  100);
  67.         $this->form->addQuickField('DATABAIXA'$DATABAIXA,  100);
  68.         $this->form->addQuickField('HORABAIXA'$HORABAIXA,  200);
  69.         $this->form->addQuickField('COBRANCA'$COBRANCA,  200);
  70.         $this->form->addQuickField('VALORCOBRADO'$VALORCOBRADO,  100);
  71.         $this->form->addQuickField('TPSERVICO'$TPSERVICO,  200);
  72.         $this->form->addQuickField('AB_TECNICO'$AB_TECNICO,  100);
  73.         $this->form->addQuickField('FC_TECNICO'$FC_TECNICO,  100);
  74.         $this->form->addQuickField('TECNICO'$TECNICO,  100);
  75.         $this->form->addQuickField('DT_DESPACHO'$DT_DESPACHO,  100);
  76.         $this->form->addQuickField('HR_DESPACHO'$HR_DESPACHO,  200);
  77.         
  78.         // create the form actions
  79.         $this->form->addQuickAction(_t('Save'), new TAction(array($this'onSave')), 'ico_save.png');
  80.         $this->form->addQuickAction(_t('New'),  new TAction(array($this'onEdit')), 'ico_new.png');
  81.         
  82.         // add the form to the page
  83.         parent::add($this->form);
  84.     }
  85. }
  1. <?php
  2. /**
  3.  * SuporteList Listing
  4.  * @author  <your name here>
  5.  */
  6. class SuporteList 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.         parent::setDatabase('prov');            // defines the database
  21.         parent::setActiveRecord('Suporte');   // defines the active record
  22.         parent::setDefaultOrder('CODIGO''asc');         // defines the default order
  23.         parent::addFilterField('CODIGO''like'); // add a filter field
  24.         parent::addFilterField('CLIENTE''like'); // add a filter field
  25.         parent::addFilterField('PESSOAATENDIDA''like'); // add a filter field
  26.         
  27.         // creates the form, with a table inside
  28.         $this->form = new TQuickForm('form_search_Suporte');
  29.         $this->form->class 'tform'// CSS class
  30.         $this->form->setFormTitle('Suporte');
  31.         
  32.         // create the form fields
  33.         $CODIGO                         = new TEntry('CODIGO');
  34.         $CLIENTE                        = new TEntry('CLIENTE');
  35.         $PESSOAATENDIDA                 = new TEntry('PESSOAATENDIDA');
  36.         
  37.         
  38.      
  39.         // add the fields
  40.         $this->form->addQuickField('CODIGO'$CODIGO,  100);
  41.         $this->form->addQuickField('CLIENTE'$CLIENTE,  100);
  42.         $this->form->addQuickField('PESSOAATENDIDA'$PESSOAATENDIDA,  200);
  43.         
  44.         // keep the form filled during navigation with session data
  45.         $this->form->setDataTSession::getValue('Suporte_filter_data') );
  46.         
  47.         // add the search form actions
  48.         $this->form->addQuickAction(_t('Find'), new TAction(array($this'onSearch')), 'ico_find.png');
  49.     //    $this->form->addQuickAction(_t('New'),  new TAction(array('SuporteForm', 'onEdit')), 'ico_new.png');
  50.         
  51.         // creates a DataGrid
  52.         $this->datagrid = new TQuickGrid;
  53.         $this->datagrid->setHeight(320);
  54.         
  55.                      
  56.         // creates the datagrid columns
  57.         $CODIGO $this->datagrid->addQuickColumn('CODIGO''CODIGO''right'100);
  58.         $CLIENTE $this->datagrid->addQuickColumn('CLIENTE_ID''CLIENTE_ID''right'100);
  59.         $RAZAOSOCIAL $this->datagrid->addQuickColumn('RAZAOSOCIAL''cliente_name''left'250); /// O ERRO ESTA AQUI EU ACHO !!!
  60.         $TITULOPROBLEMA $this->datagrid->addQuickColumn('TITULOPROBLEMA''TITULOPROBLEMA''left'200);
  61.         $DATARECLAMACAO $this->datagrid->addQuickColumn('DATARECLAMACAO''DATARECLAMACAO''left'100);
  62.         $HORARECLAMACAO $this->datagrid->addQuickColumn('HORARECLAMACAO''HORARECLAMACAO''left'200);
  63.         $PESSOAATENDIDA $this->datagrid->addQuickColumn('PESSOAATENDIDA''PESSOAATENDIDA''left'200);
  64.         $DESCRICAOPROBLEMA $this->datagrid->addQuickColumn('DESCRICAOPROBLEMA''DESCRICAOPROBLEMA''left'200);
  65.         
  66.         // create the datagrid actions
  67.         $edit_action   = new TDataGridAction(array('SuporteForm''onEdit'));
  68.         $delete_action = new TDataGridAction(array($this'onDelete'));
  69.         
  70.         // add the actions to the datagrid
  71.     //    $this->datagrid->addQuickAction(_t('Edit'), $edit_action, 'CODIGO', 'ico_edit.png');
  72.      //   $this->datagrid->addQuickAction(_t('Delete'), $delete_action, 'CODIGO', 'ico_delete.png');
  73.         
  74.         // create the datagrid model
  75.         $this->datagrid->createModel();
  76.         
  77.         // create the page navigation
  78.         $this->pageNavigation = new TPageNavigation;
  79.         $this->pageNavigation->setAction(new TAction(array($this'onReload')));
  80.         $this->pageNavigation->setWidth($this->datagrid->getWidth());
  81.         
  82.         // create the page container
  83.         $container TVBox::pack$this->form$this->datagrid$this->pageNavigation);
  84.         parent::add($container);
  85.     }
  86. }

Curso completo Meu Negócio Pronto
Use para si, ou transforme em um negócio: Inclui aulas e códigos-fontes
Gestor de conteúdo (SITE) + Loja Virtual (E-Commerce) + Emissor de Notas para infoprodutos


Meu negócio pronto Quero me inscrever agora!

Comentários (6)


FC

Você está certo.

$RAZAOSOCIAL = $this->datagrid->addQuickColumn('Aqui é o Label', 'RAZAOSOCIAL', 'left', 250); /// O ERRO ESTA AQUI EU ACHO !!!

Isso mesmo no data grid rápido (TStandardList) o primeiro campo é o Label o segundo deve ser o nome do campo da tabela/model

PD

Paulo,

Leia este artigo que eu escrevi, vai elucidar esta questão:
www.adianti.com.br/forum/pt/view_876?pensando-em-objetos-nao-em-sql-

Você precisa fazer um método get_cliente() na classe model Suporte. Este método
deverá retornar o objeto cliente relacionado;
  1. <?php
  2. class Suporte
  3. {
  4.     public function get_cliente()
  5.     {
  6.         return new Cliente$this->CLIENTE ); // supondo que esta é a chave estrangeira para cliente
  7.     }
  8. }
  9. ?>

E então usar esse atributo na datagrid:
"cliente->RAZAOSOCIAL"

  1. <?php
  2. $this->datagrid->addQuickColumn('Aqui é o Label''cliente->RAZAOSOCIAL''left'250);
  3. ?>


Outra coisa, procure seguir padrões de nomenclatura em banco de dados.
Não há motivos para usar tudo em maiúsculo. Chaves estrangeiras devem se chamar
cliente_id ou id_cliente, tornando mais fácil a leitura. São padrões globais ;-)

Att,
Pablo
FK

mas como altero por exemplo o nome dos label do TDBSeekButton, por exemplo eu tenho um campo onde vou buscar os nomes até ai eu entendi , mas na hora de clicar sobre a lupa(de buscar) ele aparece uma nova janela modal com a listagem das cidades(ou qualquer outro banco de dados previamente setado) o problema tá no cabeçalho da coluna que aparece :
ID | FIELD | FIELD |
eu queria que aparecece
LOCAL | Nome do Local | Catagoria
como mudo os cabeçalhos???
PD

Fernando,

O TDBseekButton faz um simplão mesmo.
Se você quiser personalizar, tem de partir para seek manual:
www.adianti.com.br/framework_files/tutor/index.php?class=FormSeekBut
www.adianti.com.br/framework_files/tutor/index.php?class=CitySeek

Att,
CC

Estou com o mesmo problema e mesmo consultando o livro, as vídeo-Aulas e este fórum não consegui resolver... segue meu código para ver se pelo algum fera pode me ajudar...

Código da Model...

  1. <?php
  2. /**
  3.  * GCidade Active Record
  4.  * @author  <your-name-here>
  5.  */
  6. class GCidade extends TRecord
  7. {
  8.     const TABLENAME 'gcidade';
  9.     const PRIMARYKEY'id';
  10.     const IDPOLICY =  'max'// {max, serial}
  11.     
  12.     
  13.     private $gestado;
  14.     /**
  15.      * Constructor method
  16.      */
  17.     public function __construct($id NULL$callObjectLoad TRUE)
  18.     {
  19.         parent::__construct($id$callObjectLoad);
  20.         parent::addAttribute('gciCidade');
  21.         parent::addAttribute('gestado_id');
  22.     }
  23.     
  24.     /**
  25.      * Method set_gestado
  26.      * Sample of usage: $gcidade->gestado = $object;
  27.      * @param $object Instance of GEstado
  28.      */
  29.     public function set_gestado(GEstado $object)
  30.     {
  31.         $this->gestado $object;
  32.         $this->gestado_id $object->id;
  33.     }
  34.     
  35.     /**
  36.      * Method get_gestado
  37.      * Sample of usage: $gcidade->gestado->attribute;
  38.      * @returns GEstado instance
  39.      */
  40.     public function get_gestado()
  41.     {
  42.         // loads the associated object
  43.         if (empty($this->gestado))
  44.             $this->gestado = new GEstado($this->gestado_id);
  45.     
  46.         // returns the associated object
  47.         return $this->gestado;
  48.         return new estado$this->gestado_id );
  49.     }
  50.     
  51.     
  52.     /**
  53.      * Method getMMembros
  54.      */
  55.     public function getMMembros()
  56.     {
  57.         $criteria = new TCriteria;
  58.         $criteria->add(new TFilter('gcidade_id''='$this->id));
  59.         return MMembro::getObjects$criteria ); // visto do exemplo do Pablo...
  60.     }
  61.     
  62. }
  63. ?>


Código da Control...

  1. <?php
  2. /**
  3.  * forCadCidade Form List
  4.  * @author  <your name here>
  5.  */
  6. class forCadCidade extends TPage
  7. {
  8.     protected $form// form
  9.     protected $datagrid// datagrid
  10.     protected $pageNavigation;
  11.     protected $loaded;
  12.     
  13.     /**
  14.      * Form constructor
  15.      * @param $param Request
  16.      */
  17.     public function __construct$param )
  18.     {
  19.         parent::__construct();
  20.         
  21.         // creates the form
  22.         $this->form = new TQuickForm('form_GCidade');
  23.         $this->form->class 'tform'// change CSS class
  24.         $this->form = new BootstrapFormWrapper($this->form);
  25.         $this->form->style 'display: table;width:100%'// change style
  26.         $this->form->setFormTitle('GCidade');
  27.         
  28.         // create the form fields
  29.         $id = new TEntry('id');
  30.         $gestado_id = new TEntry('gestado_id');
  31.         $gciCidade = new TEntry('gciCidade');
  32.         // add the fields
  33.         $this->form->addQuickField('Id'$id,  100 );
  34.         $this->form->addQuickField('Estado'$gestado_id,  200 , new TRequiredValidator);
  35.         $this->form->addQuickField('Cidade'$gciCidade,  200 , new TRequiredValidator);
  36.         /** samples
  37.          $this->form->addQuickFields('Date', array($date1, new TLabel('to'), $date2)); // side by side fields
  38.          $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
  39.          $fieldX->setSize( 100, 40 ); // set size
  40.          **/
  41.          
  42.         // create the form actions
  43.         $this->form->addQuickAction(_t('Save'), new TAction(array($this'onSave')), 'fa:floppy-o');
  44.         $this->form->addQuickAction(_t('New'),  new TAction(array($this'onClear')), 'bs:plus-sign green');
  45.         
  46.         // creates a Datagrid
  47.         $this->datagrid = new TDataGrid;
  48.         ##LIST_DECORATOR##
  49.         $this->datagrid->style 'width: 100%';
  50.         $this->datagrid->setHeight(320);
  51.         // $this->datagrid->datatable = 'true';
  52.         // $this->datagrid->enablePopover('Popover', 'Hi <b> {name} </b>');
  53.         
  54.         // creates the datagrid columns
  55.         $column_id = new TDataGridColumn('id''Id''left');
  56.         $column_gestado_id = new TDataGridColumn('gestado_id -> estado''Estado''left'); // visto do exemplo do Pablo...
  57.         $column_gciCidade = new TDataGridColumn('gciCidade''Cidade''left');
  58.         // add the columns to the DataGrid
  59.         $this->datagrid->addColumn($column_id);
  60.         $this->datagrid->addColumn($column_gestado_id);
  61.         $this->datagrid->addColumn($column_gciCidade);
  62.         
  63.         // creates two datagrid actions
  64.         $action1 = new TDataGridAction(array($this'onEdit'));
  65.         $action1->setUseButton(TRUE);
  66.         $action1->setButtonClass('btn btn-default');
  67.         $action1->setLabel(_t('Edit'));
  68.         $action1->setImage('fa:pencil-square-o blue fa-lg');
  69.         $action1->setField('id');
  70.         
  71.         $action2 = new TDataGridAction(array($this'onDelete'));
  72.         $action2->setUseButton(TRUE);
  73.         $action2->setButtonClass('btn btn-default');
  74.         $action2->setLabel(_t('Delete'));
  75.         $action2->setImage('fa:trash-o red fa-lg');
  76.         $action2->setField('id');
  77.         
  78.         // add the actions to the datagrid
  79.         $this->datagrid->addAction($action1);
  80.         $this->datagrid->addAction($action2);
  81.         
  82.         // create the datagrid model
  83.         $this->datagrid->createModel();
  84.         
  85.         // creates the page navigation
  86.         $this->pageNavigation = new TPageNavigation;
  87.         $this->pageNavigation->setAction(new TAction(array($this'onReload')));
  88.         $this->pageNavigation->setWidth($this->datagrid->getWidth());
  89.         
  90.         // vertical box container
  91.         $container = new TVBox;
  92.         $container->style 'width: 90%';
  93.         // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  94.         $container->add(TPanelGroup::pack('Title'$this->form));
  95.         $container->add($this->datagrid);
  96.         $container->add($this->pageNavigation);
  97.         
  98.         parent::add($container);
  99.     }
  100.     /**
  101.      * Load the datagrid with data
  102.      */
  103.     public function onReload($param NULL)
  104.     {
  105.         try
  106.         {
  107.             // open a transaction with database 'consimpro'
  108.             TTransaction::open('consimpro');
  109.             
  110.             // creates a repository for GCidade
  111.             $repository = new TRepository('GCidade');
  112.             $limit 10;
  113.             // creates a criteria
  114.             $criteria = new TCriteria;
  115.             
  116.             // default order
  117.             if (empty($param['order']))
  118.             {
  119.                 $param['order'] = 'id';
  120.                 $param['direction'] = 'asc';
  121.             }
  122.             $criteria->setProperties($param); // order, offset
  123.             $criteria->setProperty('limit'$limit);
  124.             
  125.             if (TSession::getValue('GCidade_filter'))
  126.             {
  127.                 // add the filter stored in the session to the criteria
  128.                 $criteria->add(TSession::getValue('GCidade_filter'));
  129.             }
  130.             
  131.             // load the objects according to criteria
  132.             $objects $repository->load($criteriaFALSE);
  133.             
  134.             $this->datagrid->clear();
  135.             if ($objects)
  136.             {
  137.                 // iterate the collection of active records
  138.                 foreach ($objects as $object)
  139.                 {
  140.                     // add the object inside the datagrid
  141.                     $this->datagrid->addItem($object);
  142.                 }
  143.             }
  144.             
  145.             // reset the criteria for record count
  146.             $criteria->resetProperties();
  147.             $count$repository->count($criteria);
  148.             
  149.             $this->pageNavigation->setCount($count); // count of records
  150.             $this->pageNavigation->setProperties($param); // order, page
  151.             $this->pageNavigation->setLimit($limit); // limit
  152.             
  153.             // close the transaction
  154.             TTransaction::close();
  155.             $this->loaded true;
  156.         }
  157.         catch (Exception $e// in case of exception
  158.         {
  159.             // shows the exception error message
  160.             new TMessage('error''<b>Error</b> ' $e->getMessage());
  161.             
  162.             // undo all pending operations
  163.             TTransaction::rollback();
  164.         }
  165.     }
  166.     
  167.     /**
  168.      * Ask before deletion
  169.      */
  170.     public function onDelete($param)
  171.     {
  172.         // define the delete action
  173.         $action = new TAction(array($this'Delete'));
  174.         $action->setParameters($param); // pass the key parameter ahead
  175.         
  176.         // shows a dialog to the user
  177.         new TQuestion(TAdiantiCoreTranslator::translate('Do you really want to delete ?'), $action);
  178.     }
  179.     
  180.     /**
  181.      * Delete a record
  182.      */
  183.     public function Delete($param)
  184.     {
  185.         try
  186.         {
  187.             $key=$param['key']; // get the parameter $key
  188.             TTransaction::open('consimpro'); // open a transaction with database
  189.             $object = new GCidade($keyFALSE); // instantiates the Active Record
  190.             $object->delete(); // deletes the object from the database
  191.             TTransaction::close(); // close the transaction
  192.             $this->onReload$param ); // reload the listing
  193.             new TMessage('info'TAdiantiCoreTranslator::translate('Record deleted')); // success message
  194.         }
  195.         catch (Exception $e// in case of exception
  196.         {
  197.             new TMessage('error''<b>Error</b> ' $e->getMessage()); // shows the exception error message
  198.             TTransaction::rollback(); // undo all pending operations
  199.         }
  200.     }
  201.     
  202.     /**
  203.      * Save form data
  204.      * @param $param Request
  205.      */
  206.     public function onSave$param )
  207.     {
  208.         try
  209.         {
  210.             TTransaction::open('consimpro'); // open a transaction
  211.             
  212.             /**
  213.             // Enable Debug logger for SQL operations inside the transaction
  214.             TTransaction::setLogger(new TLoggerSTD); // standard output
  215.             TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  216.             **/
  217.             
  218.             $this->form->validate(); // validate form data
  219.             
  220.             $object = new GCidade;  // create an empty object
  221.             $data $this->form->getData(); // get form data as array
  222.             $object->fromArray( (array) $data); // load the object with data
  223.             $object->store(); // save the object
  224.             
  225.             // get the generated id
  226.             $data->id $object->id;
  227.             
  228.             $this->form->setData($data); // fill form data
  229.             TTransaction::close(); // close the transaction
  230.             
  231.             new TMessage('info'TAdiantiCoreTranslator::translate('Record saved')); // success message
  232.             $this->onReload(); // reload the listing
  233.         }
  234.         catch (Exception $e// in case of exception
  235.         {
  236.             new TMessage('error'$e->getMessage()); // shows the exception error message
  237.             $this->form->setData$this->form->getData() ); // keep form data
  238.             TTransaction::rollback(); // undo all pending operations
  239.         }
  240.     }
  241.     
  242.     /**
  243.      * Clear form data
  244.      * @param $param Request
  245.      */
  246.     public function onClear$param )
  247.     {
  248.         $this->form->clear();
  249.     }
  250.     
  251.     /**
  252.      * Load object to form data
  253.      * @param $param Request
  254.      */
  255.     public function onEdit$param )
  256.     {
  257.         try
  258.         {
  259.             if (isset($param['key']))
  260.             {
  261.                 $key $param['key'];  // get the parameter $key
  262.                 TTransaction::open('consimpro'); // open a transaction
  263.                 $object = new GCidade($key); // instantiates the Active Record
  264.                 $this->form->setData($object); // fill the form
  265.                 TTransaction::close(); // close the transaction
  266.             }
  267.             else
  268.             {
  269.                 $this->form->clear();
  270.             }
  271.         }
  272.         catch (Exception $e// in case of exception
  273.         {
  274.             new TMessage('error'$e->getMessage()); // shows the exception error message
  275.             TTransaction::rollback(); // undo all pending operations
  276.         }
  277.     }
  278.     
  279.     /**
  280.      * method show()
  281.      * Shows the page
  282.      */
  283.     public function show()
  284.     {
  285.         // check if the datagrid is already loaded
  286.         if (!$this->loaded AND (!isset($_GET['method']) OR $_GET['method'] !== 'onReload') )
  287.         {
  288.             $this->onReloadfunc_get_arg(0) );
  289.         }
  290.         parent::show();
  291.     }
  292. }
  293. ?>


No aguardo...</your>
PD

Cleiton,

Evite criar comentários em POSTS antigos já resolvidos.
Dificulta a pesquisa e prejudica os registros.
Prefira abrir POSTS novos.

Seu método get_gestado() está com 2 returns.

Além disso, a sintaxe usada na datagrid está errada.
Você usou:
gestado_id -> estado

Quando o correto é:
estado->nome

Veja o exemplo CustomerDataGridView do tutor que tem um exemplo funcionando:
Retorna o nome da cidade. Primeiro dá um get_city(), e a partir dele, retorna o name:
$this->datagrid->addQuickColumn('City', 'city->name', 'left', 140, new TAction(array($this, 'onReload')), array('order', 'city->name'));

Att,