Lançado Adianti Framework 8.1!
Clique aqui para saber mais
duas tabelas no arquivo ClienteFrom.class no arquivo ClienteForm.class pretendo mostrar duas tabelas: ...
LG
duas tabelas no arquivo ClienteFrom.class  
no arquivo ClienteForm.class pretendo mostrar duas tabelas:

  1. <?php
  2. function onReload($param NULL)
  3.     {
  4.         try
  5.         {
  6.         TTransaction::open('conexao');     
  7.         $repository = new TRepository('VContasreceber');
  8.         $criteria = new TCriteria;
  9.         $criteria->add( new TFilter'ID_CLIENTE''=''$ID_CLIENTE' )); 
  10.         $objects $repository->load$criteria );
  11.             
  12.             $this->datagrid->clear();
  13.             
  14.             if($objects)
  15.             {
  16.                 foreach($objects as $object)
  17.                 {                    
  18.                     $this->datagrid->addItem($object);
  19.                 }
  20.          }
  21. ?>

  1. <?php
  2. /**
  3.  * ClienteForm Registration
  4.  * @author  <your name here>
  5.  */
  6. class ClienteForm extends TWindow
  7. {
  8.     protected $form// form
  9.     
  10.     use Adianti\Base\AdiantiStandardFormTrait// Standard form methods
  11.     
  12.     /**
  13.      * Class constructor
  14.      * Creates the page and the registration form 
  15.      */
  16.      
  17.     
  18.     
  19.     function __construct()
  20.     {
  21.         parent::__construct();
  22.         
  23.      
  24.         
  25.         $this->setDatabase('conexao');              // defines the database
  26.         $this->setActiveRecord('Cliente');     // defines the active record 
  27.         // creates the form
  28.         $this->form = new TQuickForm('form_Cliente');
  29.         $this->form->class 'tform'// change CSS class
  30.         $this->form->style 'display: table;width:100%'// change style
  31.         
  32.       
  33.         
  34.         // create the HTML Renderer
  35.         // define the form title
  36.         //$this->form->setTitle('Dados Cadastrais:');
  37.         $titulos =new TLabel('Dados Cadastrais:');
  38.         $titulos->Style="color: white;font-weight: bold; ";
  39.         $row $this->form->addRow();
  40.          $row->style "background-color:#2989e0; height: 42px; -moz-border-radius: 10px; ";
  41.         // $row->class = 'tformsection';
  42.          $row->addCell($titulos)->colspan =23;
  43.            $row $this->form->addRow();
  44.          $row->style "background-color:#2989e0; height: 9px;  ";
  45.         
  46.         $CODIGO = new TLabel('');
  47.         $CODIGO ->setName('CODIGO');  
  48.         $RAZAO_SOCIAL = new TLabel('');
  49.         $RAZAO_SOCIAL ->setName('RAZAO_SOCIAL');  
  50.         $NOME_FANTASIA = new TLabel('');
  51.         $NOME_FANTASIA->setName('NOME_FANTASIA');  
  52.         $ENDERECO = new TLabel('');        
  53.         $ENDERECO->setName('ENDERECO');  
  54.         $NUMERO = new TLabel('');
  55.         $NUMERO->setName('NUMERO');
  56.         $COMPLEMENTO = new TLabel('');
  57.         $COMPLEMENTO->setName('COMPLEMENTO');        
  58.         $BAIRRO = new TLabel('');
  59.         $BAIRRO->setName('BAIRRO');   
  60.         $ID_CIDADE= new TLabel('');
  61.         $ID_CIDADE->setName('NOME_CIDADE');
  62.         $estado= new TLabel('');
  63.         $estado->setName('UF');
  64.         $FONE = new TLabel('');
  65.         $FONE->setName('FONE');   
  66.         $CELULAR = new TLabel('');
  67.         $CELULAR->setName('CELULAR');  
  68.         $EMAIL = new TLabel('');
  69.         $EMAIL->setName('EMAIL');  
  70.         $CNPJCPF = new TLabel('');
  71.         $CNPJCPF->setName('CNPJCPF');
  72.         $IDENTINSC = new TLabel('');
  73.         $IDENTINSC->setName('IDENTINSC');
  74.         $vazio = new TLabel('');
  75.         // add the fields
  76.         $titulos =new TLabel('Titulos Abertos:');
  77.         $titulos->Style="color: white;font-weight: bold";        
  78.         $this->form->addQuickField('Codigo:',$CODIGO700 );
  79.         $this->form->addQuickField('Razao Social:'$RAZAO_SOCIAL,  500 );
  80.         $this->form->addQuickField('Nome Fantasia:'$NOME_FANTASIA,  500 );       
  81.         $this->form->addQuickFields('Endereço:', array($ENDERECO$NUMERO$COMPLEMENTO));
  82.         $this->form->addQuickField('Bairro:'$BAIRRO,  500 );
  83.         $this->form->addQuickField('Cidade:'$ID_CIDADE);
  84.         $this->form->addQuickField('Estado:'$estado,  500 );
  85.         $this->form->addQuickFields('Telefone/Celular:', array($FONE,$CELULAR));
  86.         $this->form->addQuickField('Email:'$EMAIL,  500 );        
  87.         $this->form->addQuickField('CNPJ/CPF:'$CNPJCPF,500);
  88.         $this->form->addQuickField('Identidade/Inscrição:'$IDENTINSC,500);
  89.         //$this->form->addQuickField('', $vazio,500);
  90.         $row $this->form->addRow();
  91.         $row->style "background-color:#2989e0; height: 9px;  ";
  92.         $row $this->form->addRow();
  93.         $row->style "background-color:#2989e0; height: 42px;border-radius: 10px  ";
  94.         // $row->class = 'tformsection';
  95.         $row->addCell($titulos)->colspan =23;
  96.        
  97.      
  98.         
  99.          
  100.         /*$this->datagrid = new TDataGrid;
  101.         $this->datagrid->disableDefaultClick(); // important!        
  102.         $this->datagrid->style = 'width: 100%';
  103.         $this->datagrid->setHeight(320);
  104.         $this->datagrid->addQuickColumn('Nota', 'NUMERO_NOTA', 'left', 40, new TAction(array($this, 'onReload')), array('NUMERO_NOTA'));*/
  105.         /* $this->datagrid->addQuickColumn('Série', 'name', 'left', 170);
  106.         $this->datagrid->addQuickColumn('Emissão', 'city->name', 'left', 140);
  107.         $this->datagrid->addQuickColumn('Documento', 'address', 'left', 190);
  108.         $this->datagrid->addQuickColumn('Vencimento', 'address', 'left', 190);
  109.         $this->datagrid->addQuickColumn('Valor', 'address', 'left', 190);
  110.         $this->datagrid->addQuickColumn('Tipo', 'address', 'left', 190);*/
  111.        // $this->datagrid->createModel();
  112.         
  113.          
  114.          
  115.          
  116.          
  117.         
  118.         if (!empty($ID_CLIENTE))
  119.         {
  120.             $ID_CLIENTE->setEditable(FALSE);
  121.         }
  122.         
  123.         /** samples
  124.          $this->form->addQuickFields('Date', array($date1, new TLabel('to'), $date2)); // side by side fields
  125.          $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
  126.          $fieldX->setSize( 100, 40 ); // set size
  127.          **/
  128.          
  129.         // create the form actions
  130.         //$this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'fa:floppy-o');
  131.         //$this->form->addQuickAction(_t('New'),  new TAction(array($this, 'onEdit')), 'bs:plus-sign green');
  132.         
  133.     
  134.         
  135.         
  136.         // vertical box container
  137.         $container = new TVBox;
  138.         $container->style 'width: 100%; ';
  139.         // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  140.         $container->add($this->form);
  141.         
  142.         
  143. parent::setTitle('Detalhes do Cliente:');
  144.     
  145.         parent::add($container);
  146.     }
  147. }
  148. Mas nao estou conseguindo.
  149. Segue imagemComforme a mesma queria colocar a respectiva tabela Vcontasreceber(modelabaixo do texto Titulos abertos:

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 (4)


NR

Você criou a função onReload, mas ela está sendo chamada? E essa função está adicionando itens em uma datagrid, mas pelo que vi no construtor a instância da variável $this->datagrid está comentada, ou seja, essa variável não existe
LG



  1. <?php
  2. function onReload($param NULL)
  3. {
  4.   try{
  5.             if (isset($param['key'])){
  6.                 $key=$param['key'];
  7.                 
  8.               $repository = new TRepository('VContasreceber');
  9.               $criteria = new TCriteria;
  10.               $criteria->add( new TFilter'ID_CLIENTE''='$key ));
  11.               
  12.               $objects $repository->load$criteria );
  13.             
  14.               $this->datagrid->clear();
  15.             
  16.          if($objects)
  17.          {
  18.            foreach($objects as $object)
  19.            {                    
  20.              $this->datagrid->addItem($object);
  21.            }
  22.          }
  23.             TTransaction::close();          
  24.             } else {
  25.                 
  26.              $this->datagrid->clear();
  27.             }
  28.         }
  29.         catch (Exception $e){
  30.             new TMessage('error''<b>Error</b> ' $e->getMessage());
  31.             TTransaction::rollback();
  32.         }
  33. }
  34. ?>


  1. <?php
  2. /**
  3.  * ClienteForm Registration
  4.  * @author  <your name here>
  5.  */
  6. class ClienteForm extends TWindow
  7. {
  8.     protected $form// form
  9.     protected $datagrid;  // listing
  10.     protected $formgrid;
  11.     protected $pageNavigation;
  12.     protected $loaded;
  13.     protected $transformCallback;
  14.     use Adianti\Base\AdiantiStandardFormTrait// Standard form methods
  15.     
  16.     /**
  17.      * Class constructor
  18.      * Creates the page and the registration form 
  19.      */
  20.      
  21.     function __construct()
  22.     {
  23.         parent::__construct();
  24.         
  25.      
  26.         
  27.         $this->setDatabase('conexao');              // defines the database
  28.         $this->setActiveRecord('Cliente');     // defines the active record 
  29.          
  30.         // creates the form
  31.         $this->form = new TQuickForm('form_Cliente');
  32.         $this->form->class 'tform'// change CSS class
  33.         $this->form->style 'display: table;width:100%'// change style
  34.         
  35.       
  36.         
  37.         // create the HTML Renderer
  38.         // define the form title
  39.         //$this->form->setTitle('Dados Cadastrais:');
  40.         $titulos =new TLabel('Dados Cadastrais:');
  41.         $titulos->Style="color: white;font-weight: bold; ";
  42.         $row $this->form->addRow();
  43.         $row->style "background-color:#2989e0; height: 42px; -moz-border-radius: 10px; ";
  44.         // $row->class = 'tformsection';
  45.         $row->addCell($titulos)->colspan =23;
  46.         $row $this->form->addRow();
  47.         $row->style "background-color:#2989e0; height: 9px;  ";
  48.         
  49.         $CODIGO = new TLabel('');
  50.         $CODIGO ->setName('CODIGO');  
  51.         $RAZAO_SOCIAL = new TLabel('');
  52.         $RAZAO_SOCIAL ->setName('RAZAO_SOCIAL');  
  53.         $NOME_FANTASIA = new TLabel('');
  54.         $NOME_FANTASIA->setName('NOME_FANTASIA');  
  55.         $ENDERECO = new TLabel('');        
  56.         $ENDERECO->setName('ENDERECO');  
  57.         $NUMERO = new TLabel('');
  58.         $NUMERO->setName('NUMERO');
  59.         $COMPLEMENTO = new TLabel('');
  60.         $COMPLEMENTO->setName('COMPLEMENTO');        
  61.         $BAIRRO = new TLabel('');
  62.         $BAIRRO->setName('BAIRRO');   
  63.         $ID_CIDADE= new TLabel('');
  64.         $ID_CIDADE->setName('NOME_CIDADE');
  65.         $estado= new TLabel('');
  66.         $estado->setName('UF');
  67.         $FONE = new TLabel('');
  68.         $FONE->setName('FONE');   
  69.         $CELULAR = new TLabel('');
  70.         $CELULAR->setName('CELULAR');  
  71.         $EMAIL = new TLabel('');
  72.         $EMAIL->setName('EMAIL');  
  73.         $CNPJCPF = new TLabel('');
  74.         $CNPJCPF->setName('CNPJCPF');
  75.         $IDENTINSC = new TLabel('');
  76.         $IDENTINSC->setName('IDENTINSC');
  77.         $vazio = new TLabel('');
  78.         // add the fields
  79.         $titulos =new TLabel('Titulos Abertos:');
  80.         $titulos->Style="color: white;font-weight: bold";        
  81.         $this->form->addQuickField('Codigo:',$CODIGO700 );
  82.         $this->form->addQuickField('Razao Social:'$RAZAO_SOCIAL,  500 );
  83.         $this->form->addQuickField('Nome Fantasia:'$NOME_FANTASIA,  500 );       
  84.         $this->form->addQuickFields('Endereço:', array($ENDERECO$NUMERO$COMPLEMENTO));
  85.         $this->form->addQuickField('Bairro:'$BAIRRO,  500 );
  86.         $this->form->addQuickField('Cidade:'$ID_CIDADE);
  87.         $this->form->addQuickField('Estado:'$estado,  500 );
  88.         $this->form->addQuickFields('Telefone/Celular:', array($FONE,$CELULAR));
  89.         $this->form->addQuickField('Email:'$EMAIL,  500 );        
  90.         $this->form->addQuickField('CNPJ/CPF:'$CNPJCPF,500);
  91.         $this->form->addQuickField('Identidade/Inscrição:'$IDENTINSC,500);
  92.         //$this->form->addQuickField('', $vazio,500);
  93.         $row $this->form->addRow();
  94.         $row->style "background-color:#2989e0; height: 9px;  ";
  95.         $row $this->form->addRow();
  96.         $row->style "background-color:#2989e0; height: 42px;border-radius: 10px  ";
  97.         // $row->class = 'tformsection';
  98.         $row->addCell($titulos)->colspan =23;
  99.         //pegaid($ID_CLIENTE);
  100.      
  101.         $this->datagrid = new TDataGrid;
  102.         $this->datagrid->disableDefaultClick(); // important!        
  103.         $this->datagrid->style 'width: 100%';
  104.         $this->datagrid->setHeight(320);    
  105.         $this->datagrid->addQuickColumn('Nota''NUMERO_NOTA''left'40, new TAction(array($this'onReload')), array('NUMERO_NOTA'));        
  106.         $this->datagrid->createModel();  
  107.          
  108.         
  109.         if (!empty($ID_CLIENTE))
  110.         {
  111.             $ID_CLIENTE->setEditable(FALSE);
  112.         }
  113.         
  114.         /** samples
  115.          $this->form->addQuickFields('Date', array($date1, new TLabel('to'), $date2)); // side by side fields
  116.          $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
  117.          $fieldX->setSize( 100, 40 ); // set size
  118.          **/
  119.          
  120.         // create the form actions
  121.         //$this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'fa:floppy-o');
  122.         //$this->form->addQuickAction(_t('New'),  new TAction(array($this, 'onEdit')), 'bs:plus-sign green');
  123.         
  124.     
  125.         
  126.         
  127.         // vertical box container
  128.         $container = new TVBox;
  129.         $container->style 'width: 100%; ';
  130.         // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  131.         $container->add($this->form);
  132.         parent::setTitle('Detalhes do Cliente:');
  133.         parent::add($container);
  134.     }
  135.     
  136.     
  137.     
  138.     
  139.     
  140. }
  141. da o seguinte erro:
  142. Fatal errorCall to undefined method Adianti\Widget\Datagrid\TDataGrid::addQuickColumn() in C:\xampp\htdocs\framework\app\control\admin\ClienteForm.class.php on line 145</your>
NR

addQuickColumn é uma função da classe TQuickGrid e você está usando a TDataGrid
LG

... substituindo...
$this->datagrid = new TQuickGrid ;
$this->datagrid->disableDefaultClick(); // important!
$this->datagrid->style = 'width: 100%';
$this->datagrid->setHeight(320);
$this->datagrid->addQuickColumn('Nota', 'NUMERO_NOTA', 'left', 40, new TAction(array($this, 'onReload')), array('NUMERO_NOTA'));
//$this->datagrid->addQuickColumn('Nota', 'NUMERO_NOTA', 'center', 40);
$this->datagrid->createModel();


da a janela do erro:

Método AdiantiControlTAction::__construct deve receber um parâmetro do tipo Callback
Verifique se a ação (ClienteForm::onReload) existe

File: appcontroladminClienteForm.class.php : 160
AdiantiControlTAction->__construct(ClienteForm,onReload)
File: libadianticoreAdiantiCoreApplication.php : 51
ClienteForm->__construct(ClienteForm,onedit,2,2)
File: engine.php : 20
AdiantiCoreAdiantiCoreApplication::run(1)
File: engine.php : 39
TApplication::run(1)