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. $this->datagrid->clear();
  12. if($objects)
  13. {
  14. foreach($objects as $object)
  15. {
  16. $this->datagrid->addItem($object);
  17. }
  18. }
  19. ?>

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


 
  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. * Class constructor
  17. * Creates the page and the registration form
  18. */
  19. function __construct()
  20. {
  21. parent::__construct();
  22. $this->setDatabase('conexao'); // defines the database
  23. $this->setActiveRecord('Cliente'); // defines the active record
  24. // creates the form
  25. $this->form = new TQuickForm('form_Cliente');
  26. $this->form->class = 'tform'; // change CSS class
  27. $this->form->style = 'display: table;width:100%'; // change style
  28. // create the HTML Renderer
  29. // define the form title
  30. //$this->form->setTitle('Dados Cadastrais:');
  31. $titulos =new TLabel('Dados Cadastrais:');
  32. $titulos->Style="color: white;font-weight: bold; ";
  33. $row = $this->form->addRow();
  34. $row->style = "background-color:#2989e0; height: 42px; -moz-border-radius: 10px; ";
  35. // $row->class = 'tformsection';
  36. $row->addCell($titulos)->colspan =23;
  37. $row = $this->form->addRow();
  38. $row->style = "background-color:#2989e0; height: 9px; ";
  39. $CODIGO = new TLabel('');
  40. $CODIGO ->setName('CODIGO');
  41. $RAZAO_SOCIAL = new TLabel('');
  42. $RAZAO_SOCIAL ->setName('RAZAO_SOCIAL');
  43. $NOME_FANTASIA = new TLabel('');
  44. $NOME_FANTASIA->setName('NOME_FANTASIA');
  45. $ENDERECO = new TLabel('');
  46. $ENDERECO->setName('ENDERECO');
  47. $NUMERO = new TLabel('');
  48. $NUMERO->setName('NUMERO');
  49. $COMPLEMENTO = new TLabel('');
  50. $COMPLEMENTO->setName('COMPLEMENTO');
  51. $BAIRRO = new TLabel('');
  52. $BAIRRO->setName('BAIRRO');
  53. $ID_CIDADE= new TLabel('');
  54. $ID_CIDADE->setName('NOME_CIDADE');
  55. $estado= new TLabel('');
  56. $estado->setName('UF');
  57. $FONE = new TLabel('');
  58. $FONE->setName('FONE');
  59. $CELULAR = new TLabel('');
  60. $CELULAR->setName('CELULAR');
  61. $EMAIL = new TLabel('');
  62. $EMAIL->setName('EMAIL');
  63. $CNPJCPF = new TLabel('');
  64. $CNPJCPF->setName('CNPJCPF');
  65. $IDENTINSC = new TLabel('');
  66. $IDENTINSC->setName('IDENTINSC');
  67. $vazio = new TLabel('');
  68. // add the fields
  69. $titulos =new TLabel('Titulos Abertos:');
  70. $titulos->Style="color: white;font-weight: bold";
  71. $this->form->addQuickField('Codigo:',$CODIGO, 700 );
  72. $this->form->addQuickField('Razao Social:', $RAZAO_SOCIAL, 500 );
  73. $this->form->addQuickField('Nome Fantasia:', $NOME_FANTASIA, 500 );
  74. $this->form->addQuickFields('Endereço:', array($ENDERECO, $NUMERO, $COMPLEMENTO));
  75. $this->form->addQuickField('Bairro:', $BAIRRO, 500 );
  76. $this->form->addQuickField('Cidade:', $ID_CIDADE);
  77. $this->form->addQuickField('Estado:', $estado, 500 );
  78. $this->form->addQuickFields('Telefone/Celular:', array($FONE,$CELULAR));
  79. $this->form->addQuickField('Email:', $EMAIL, 500 );
  80. $this->form->addQuickField('CNPJ/CPF:', $CNPJCPF,500);
  81. $this->form->addQuickField('Identidade/Inscrição:', $IDENTINSC,500);
  82. //$this->form->addQuickField('', $vazio,500);
  83. $row = $this->form->addRow();
  84. $row->style = "background-color:#2989e0; height: 9px; ";
  85. $row = $this->form->addRow();
  86. $row->style = "background-color:#2989e0; height: 42px;border-radius: 10px ";
  87. // $row->class = 'tformsection';
  88. $row->addCell($titulos)->colspan =23;
  89. //pegaid($ID_CLIENTE);
  90. $this->datagrid = new TDataGrid;
  91. $this->datagrid->disableDefaultClick(); // important!
  92. $this->datagrid->style = 'width: 100%';
  93. $this->datagrid->setHeight(320);
  94. $this->datagrid->addQuickColumn('Nota', 'NUMERO_NOTA', 'left', 40, new TAction(array($this, 'onReload')), array('NUMERO_NOTA'));
  95. $this->datagrid->createModel();
  96. if (!empty($ID_CLIENTE))
  97. {
  98. $ID_CLIENTE->setEditable(FALSE);
  99. }
  100. /** samples
  101. $this->form->addQuickFields('Date', array($date1, new TLabel('to'), $date2)); // side by side fields
  102. $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
  103. $fieldX->setSize( 100, 40 ); // set size
  104. **/
  105. // create the form actions
  106. //$this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'fa:floppy-o');
  107. //$this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'bs:plus-sign green');
  108. // vertical box container
  109. $container = new TVBox;
  110. $container->style = 'width: 100%; ';
  111. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  112. $container->add($this->form);
  113. parent::setTitle('Detalhes do Cliente:');
  114. parent::add($container);
  115. }
  116. }
  117. da o seguinte erro:
  118. Fatal error: Call 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)