Dúvida sobre autocomplete de entry COMO FACO UM AUTOCOMPLETAR DE UM CAMPO ENTRY. TENTEI UTILIZANDO : http://www.adianti.com.br/forum/pt/view_2318 E NAO DEU CERTO...

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


NR

Exemplo do tutor:
adianti.com.br/framework_files/tutor/index.php?class=FormDBAutoSelec
LG

Nao adianta esse exemplo nao funciona segui o livro tambem nao aparece nada.
LG

...
// create the form fields
$CODIGO = new TCombo('CODIGO');
//$CODIGO = new TDBCombo('CODIGO', 'cliente', 'Cliente', 'CODIGO', 'ID_CLIENTE');
//$RAZAO_SOCIAL = new TEntry('RAZAO_SOCIAL');
$RAZAO_SOCIAL = new TDBEntry('RAZAO_SOCIAL', 'cliente', 'Cliente', 'RAZAO_SOCIAL');
$CPF = new TEntry('CPF');
$CNPJ = new TEntry('CNPJ');
$ID_CIDADE = new TEntry('ID_CIDADE');
$FONE = new TEntry('FONE');
$SITUACAO = new TEntry('SITUACAO');
LG

Digo esse exemplo nao funcionou tentei fazer conforme explicacao do livro e tutoriais.
LG

 
  1. <?php
  2. /**
  3. * ClienteList Listing
  4. * @author <your name here>
  5. */
  6. class ClienteList extends TStandardList
  7. {
  8. protected $form; // registration form
  9. protected $datagrid; // listing
  10. protected $pageNavigation;
  11. protected $formgrid;
  12. protected $deleteButton;
  13. protected $transformCallback;
  14. /**
  15. * Page constructor
  16. */
  17. public function __construct()
  18. {
  19. parent::__construct();
  20. parent::setDatabase('conexao'); // defines the database
  21. parent::setActiveRecord('Cliente'); // defines the active record
  22. parent::setDefaultOrder('ID_CLIENTE', 'asc'); // defines the default order
  23. // parent::setCriteria($criteria) // define a standard filter
  24. parent::addFilterField('CODIGO', '=', 'CODIGO'); // filterField, operator, formField
  25. parent::addFilterField('RAZAO_SOCIAL', 'like', 'RAZAO_SOCIAL'); // filterField, operator, formField
  26. parent::addFilterField('CPF', 'like', 'CPF'); // filterField, operator, formField
  27. parent::addFilterField('CNPJ', 'like', 'CNPJ'); // filterField, operator, formField
  28. parent::addFilterField('ID_CIDADE', 'like', 'ID_CIDADE'); // filterField, operator, formField
  29. parent::addFilterField('FONE', 'like', 'FONE'); // filterField, operator, formField
  30. parent::addFilterField('SITUACAO', 'like', 'SITUACAO'); // filterField, operator, formField
  31. // creates the form
  32. $this->form = new TQuickForm('form_search_Cliente');
  33. $this->form->class = 'tform'; // change CSS class
  34. $this->form->style = 'display: table;width:100%'; // change style
  35. $this->form->setFormTitle('Cliente');
  36. // $cliente = new Cliente(1);
  37. //echo $cliente->cidade->nome;
  38. // create the form fields
  39. $CODIGO = new TCombo('CODIGO');
  40. //$CODIGO = new TDBCombo('CODIGO', 'cliente', 'Cliente', 'CODIGO', 'ID_CLIENTE');
  41. //$RAZAO_SOCIAL = new TEntry('RAZAO_SOCIAL');
  42. $RAZAO_SOCIAL = new TDBEntry('RAZAO_SOCIAL', 'cliente', 'Cliente', 'RAZAO_SOCIAL');
  43. $CPF = new TEntry('CPF');
  44. $CNPJ = new TEntry('CNPJ');
  45. $ID_CIDADE = new TEntry('ID_CIDADE');
  46. $FONE = new TEntry('FONE');
  47. $SITUACAO = new TEntry('SITUACAO');
  48. // add the fields
  49. $this->form->addQuickField('Código:', $CODIGO, 600 );
  50. $this->form->addQuickField('Cliente', $RAZAO_SOCIAL, 600 );
  51. $this->form->addQuickField('CPF/CNPJ:', $CPF, 600 );
  52. $this->form->addQuickField('Situação:', $SITUACAO, 600 );
  53. // keep the form filled during navigation with session data
  54. $this->form->setData( TSession::getValue('Cliente_filter_data') );
  55. // add the search form actions
  56. $this->form->addQuickAction(_t('Find'), new TAction(array($this, 'onSearch')), 'fa:search');
  57. $this->form->addQuickAction(_t('New'), new TAction(array('ClienteForm', 'onEdit')), 'bs:plus-sign green');
  58. // creates a DataGrid
  59. $this->datagrid = new TDataGrid;
  60. $this->datagrid->disableDefaultClick(); // important!
  61. $this->datagrid->style = 'width: 100%';
  62. $this->datagrid->setHeight(320);
  63. // $this->datagrid->datatable = 'true';
  64. // $this->datagrid->enablePopover('Popover', 'Hi <b> {name} </b>');
  65. // creates the datagrid columns
  66. $column_CODIGO = new TDataGridColumn('CODIGO', 'Código', 'center');
  67. $column_RAZAO_SOCIAL = new TDataGridColumn('RAZAO_SOCIAL', 'Razão Social', 'left');
  68. $column_CPF = new TDataGridColumn('CPF', 'CPF/CNPJ', 'center');
  69. $column_CNPJ = new TDataGridColumn('CNPJ', 'CNPJ', 'center');
  70. $column_ID_CIDADE = new TDataGridColumn('unidadefederacao->DESCRICAO', 'Cidade', 'center');
  71. $column_FONE = new TDataGridColumn('FONE', 'Telefone', 'center');
  72. $column_SITUACAO = new TDataGridColumn('situacao_cli', 'Situação', 'center');
  73. //$COL= compara_cpfcnpj( $column_CPF, $column_CNPJ );
  74. // $column_CPFCNPJ = new TDataGridColumn( compara_cpfcnpj , 'CPF/CNPJ', 'center');
  75. $column_CPF->setTransformer(function($value,$object){
  76. if ($value)
  77. return $value;
  78. else
  79. return $object->CNPJ;
  80. });
  81. //$action_edit = new TDataGridAction(array($this, 'onView'));
  82. //$action->setUseButton(TRUE);
  83. //$action->setButtonClass('btn btn-info');
  84. //$this->datagrid->addQuickAction('View', $action_edit, 'ID_CLIENTE', 'fa:search');
  85. // add the columns to the DataGrid
  86. $this->datagrid->addColumn($column_CODIGO);
  87. $this->datagrid->addColumn($column_RAZAO_SOCIAL);
  88. $this->datagrid->addColumn($column_CPF);
  89. // $this->datagrid->addColumn($column_CNPJ);
  90. $this->datagrid->addColumn($column_ID_CIDADE);
  91. $this->datagrid->addColumn($column_FONE);
  92. $this->datagrid->addColumn($column_SITUACAO);
  93. // creates the datagrid column actions
  94. $order_CODIGO = new TAction(array($this, 'onReload'));
  95. $order_CODIGO->setParameter('order', 'CODIGO');
  96. $column_CODIGO->setAction($order_CODIGO);
  97. $order_RAZAO_SOCIAL = new TAction(array($this, 'onReload'));
  98. $order_RAZAO_SOCIAL->setParameter('order', 'RAZAO_SOCIAL');
  99. $column_RAZAO_SOCIAL->setAction($order_RAZAO_SOCIAL);
  100. // create EDIT action
  101. $action_edit = new TDataGridAction(array('ClienteForm', 'onedit'));
  102. //$action_edit->setUseButton(TRUE);
  103. //$action_edit->setButtonClass('btn btn-default');
  104. $action_edit->setLabel('+ Detalhes');
  105. // $action_edit->setLabel(_t('Edit'));
  106. $action_edit->setImage('ico_find.png');
  107. $action_edit->setField('ID_CLIENTE');
  108. $this->datagrid->addAction($action_edit);
  109. //$this->datagrid->addQuickAction('View', $action_edit, 'ID_CLIENTE', 'fa:search');
  110. // create DELETE action
  111. $action_del = new TDataGridAction(array($this, 'onDelete'));
  112. //$action_del->setUseButton(TRUE);
  113. //$action_del->setButtonClass('btn btn-default');
  114. $action_del->setLabel(_t('Delete'));
  115. $action_del->setImage('ico_delete.png');
  116. $action_del->setField('ID_CLIENTE');
  117. $this->datagrid->addAction($action_del);
  118. // create the datagrid model
  119. $this->datagrid->createModel();
  120. // create the page navigation
  121. $this->pageNavigation = new TPageNavigation;
  122. $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
  123. $this->pageNavigation->setWidth($this->datagrid->getWidth());
  124. // vertical box container
  125. $container = new TVBox;
  126. $container->style = 'width: 100%';
  127. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  128. $container->add($this->form);
  129. $container->add($this->datagrid);
  130. $container->add($this->pageNavigation);
  131. parent::add($container);
  132. }
  133. }
  134. </your>
NR

Leonardo, verifique o arquivo engine.php mais ou menos na linha 16, nos itens do array passado como segundo parâmetro da função array_merge. Se não tiver o item AdiantiAutocompleteService, você deve adicioná-lo
 
  1. <?php
  2. $programs = array_merge($programs, array('Adianti\Base\TStandardSeek' => TRUE, 'LoginForm' => TRUE, 'AdiantiMultiSearchService' => TRUE, 'AdiantiUploaderService' => TRUE, 'EmptyPage' => TRUE, 'MessageList'=>TRUE, 'SearchBox' => TRUE,'AdiantiAutocompleteService'=> TRUE)); // default programs
  3. ?>

LG

 
  1. <?php
  2. require_once 'init.php';
  3. class TApplication extends AdiantiCoreApplication
  4. {
  5. static public function run($debug = FALSE)
  6. {
  7. new TSession;
  8. if ($_REQUEST)
  9. {
  10. $class = isset($_REQUEST['class']) ? $_REQUEST['class'] : '';
  11. if (TSession::getValue('logged')) // logged
  12. {
  13. $programs = (array) TSession::getValue('programs'); // programs with permission
  14. $programs = array_merge($programs, array('Adianti\\Base\\TStandardSeek' => TRUE, 'LoginForm' => TRUE, 'AdiantiMultiSearchService' => TRUE, 'AdiantiUploaderService' => TRUE, 'EmptyPage' => TRUE, 'MessageList'=>TRUE, 'SearchBox' => TRUE)); // default programs
  15. if( isset($programs[$class]) )
  16. {
  17. parent::run($debug);
  18. }
  19. else
  20. {
  21. new TMessage('error', _t('Permission denied') );
  22. }
  23. }
  24. else if ($class == 'LoginForm')
  25. {
  26. parent::run($debug);
  27. }
  28. else
  29. {
  30. new TMessage('error', _t('Permission denied'), new TAction(array('LoginForm','onLogout')) );
  31. }
  32. }
  33. }
  34. }
  35. TApplication::run(TRUE);
NR

Substitua a linha 16 pelo código que passei
LG

AGORA DA UM ERRO CLIENTE.INI NO TDBENTRY.
LG

DIGO AO DIGITAR DA ESSE ERRO CLIENTE.INI
NR

O segundo parâmetro do TDBEntry deve ser o nome do arquivo do banco de dados que está no diretório app/config. No seu caso o segundo parâmetro é cliente, existe o arquivo app/config/cliente.ini?
LG

Valeu amigo consegui resolver entendi o que estava errado:
$RAZAO_SOCIAL = new TDBEntry('RAZAO_SOCIAL', 'conexao', 'Cliente', 'RAZAO_SOCIAL');

aonde é a conexao e o nome do arquivo de conexao ini achei que era o nome da tabela referida da busca