Conheça as melhorias da versão 8.0, 8.1, 8.2!
Clique aqui para saber mais
Lista de seleção de registo filtro não funciona Lista não funciona os filtros, não faz nada, digitei numero mas traz todos. ...
RS
Lista de seleção de registo filtro não funciona  
Lista não funciona os filtros, não faz nada, digitei numero mas traz todos.

 
  1. <?php
  2. /**
  3. * AgetranVagaIdosoSelectionList Record selection
  4. * @author <your name here>
  5. */
  6. class AgetranVagaIdosoSelectionList extends TPage
  7. {
  8. protected $form; // search form
  9. protected $datagrid; // listing
  10. protected $pageNavigation;
  11. use Adianti\base\AdiantiStandardListTrait;
  12. /**
  13. * Page constructor
  14. */
  15. public function __construct()
  16. {
  17. parent::__construct();
  18. $this->setDatabase('dmdbd'); // defines the database
  19. $this->setActiveRecord('AgetranVagaIdoso'); // defines the active record
  20. $this->setDefaultOrder('id', 'desc'); // defines the default order
  21. // $this->setCriteria($criteria) // define a standard filter
  22. $this->addFilterField('id', '=', 'form_id'); // filterField, operator, formField
  23. $this->addFilterField('id_idoso', '=', 'id_idoso'); // filterField, operator, formField
  24. $this->addFilterField('emissao', '=', 'emissao', function($value) {
  25. return TDate::convertToMask($value, 'dd/mm/yyyy', 'yyyy-mm-dd');
  26. }); // filterField, operator, formField, transformFunction
  27. // creates the form
  28. $this->form = new BootstrapFormBuilder('form_search_AgetranVagaIdoso');
  29. $this->form->setFormTitle('Selecionar Credências Idoso para Impressão');
  30. // create the form fields
  31. $form_id = new TEntry('form_id');
  32. $id_idoso = new TEntry('id_idoso');
  33. $emissao = new TDate('emissao');
  34. $emissao->setValue(date('d/m/Y'));
  35. // add the fields
  36. $this->form->addFields( [ new TLabel('Número') ], [ $form_id ] );
  37. $this->form->addFields( [ new TLabel('Nome') ], [ $id_idoso ] );
  38. $this->form->addFields( [ new TLabel('Emissão') ], [ $emissao ] );
  39. // set sizes
  40. $form_id->setSize('10%');
  41. $id_idoso->setSize('70%');
  42. $emissao->setSize('10%');
  43. $emissao->setMask('dd/mm/YYYY');
  44. $emissao->setOption('triggerEvent', 'dblclick');
  45. // keep the form filled during navigation with session data
  46. $this->form->setData( TSession::getValue('AgetranVagaIdoso_filter_data') );
  47. $btn = $this->form->addAction(_t('Find'), new TAction([$this, 'onSearch']), 'fa:search');
  48. $btn->class = 'btn btn-sm btn-primary';
  49. $this->form->addAction('Show results', new TAction([$this, 'showResults']), 'fa:check-circle-o green');
  50. // creates a DataGrid
  51. $this->datagrid = new BootstrapDatagridWrapper(new TDataGrid);
  52. $this->datagrid->style = 'width: 100%';
  53. $this->datagrid->datatable = 'true';
  54. // $this->datagrid->enablePopover('Popover', 'Hi <b> {name} </b>');
  55. // creates the datagrid columns
  56. $column_id = new TDataGridColumn('id', 'Número', 'right');
  57. $column_id_idoso = new TDataGridColumn('idoso->nome', 'Nome', 'left');
  58. $column_emissao = new TDataGridColumn('emissao', 'Emissão', 'left');
  59. $column_uf = new TDataGridColumn('uf', 'UF', 'left');
  60. $column_cidade = new TDataGridColumn('cidade', 'Cidade', 'left');
  61. $column_orgao_expedidor = new TDataGridColumn('orgao_expedidor', 'Orgao Expedidor', 'left');
  62. $column_validade = new TDataGridColumn('validade', 'Validade', 'left');
  63. // add the columns to the DataGrid
  64. $this->datagrid->addColumn($column_id);
  65. $this->datagrid->addColumn($column_id_idoso);
  66. $this->datagrid->addColumn($column_emissao);
  67. $this->datagrid->addColumn($column_uf);
  68. $this->datagrid->addColumn($column_cidade);
  69. $this->datagrid->addColumn($column_orgao_expedidor);
  70. $this->datagrid->addColumn($column_validade);
  71. $column_emissao->setTransformer( function($value, $object, $row) {
  72. $date = new DateTime($value);
  73. return $date->format('d/m/Y');
  74. });
  75. $column_validade->setTransformer( function($value, $object, $row) {
  76. $date = new DateTime($value);
  77. return $date->format('d/m/Y');
  78. });
  79. // creates the datagrid column actions
  80. $column_id->setAction(new TAction([$this, 'onReload']), ['order' => 'id']);
  81. $column_emissao->setAction(new TAction([$this, 'onReload']), ['order' => 'emissao']);
  82. $column_id->setTransformer([$this, 'formatRow'] );
  83. // creates the datagrid actions
  84. $action1 = new TDataGridAction([$this, 'onSelect']);
  85. $action1->setUseButton(TRUE);
  86. $action1->setButtonClass('btn btn-default');
  87. $action1->setLabel(AdiantiCoreTranslator::translate('Select'));
  88. $action1->setImage('fa:check-circle-o blue');
  89. $action1->setField('id');
  90. // add the actions to the datagrid
  91. $this->datagrid->addAction($action1);
  92. // create the datagrid model
  93. $this->datagrid->createModel();
  94. // create the page navigation
  95. $this->pageNavigation = new TPageNavigation;
  96. $this->pageNavigation->setAction(new TAction([$this, 'onReload']));
  97. $this->pageNavigation->setWidth($this->datagrid->getWidth());
  98. // vertical box container
  99. $container = new TVBox;
  100. $container->style = 'width: 90%';
  101. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  102. $container->add($this->form);
  103. $container->add(TPanelGroup::pack('', $this->datagrid, $this->pageNavigation));
  104. parent::add($container);
  105. }
  106. /**
  107. * Save the object reference in session
  108. */
  109. public function onSelect($param)
  110. {
  111. // get the selected objects from session
  112. $selected_objects = TSession::getValue(__CLASS__.'_selected_objects');
  113. TTransaction::open('dmdbd');
  114. $object = new AgetranVagaIdoso($param['key']); // load the object
  115. if (isset($selected_objects[$object->id]))
  116. {
  117. unset($selected_objects[$object->id]);
  118. }
  119. else
  120. {
  121. $selected_objects[$object->id] = $object->toArray(); // add the object inside the array
  122. }
  123. TSession::setValue(__CLASS__.'_selected_objects', $selected_objects); // put the array back to the session
  124. TTransaction::close();
  125. // reload datagrids
  126. $this->onReload( func_get_arg(0) );
  127. }
  128. /**
  129. * Highlight the selected rows
  130. */
  131. public function formatRow($value, $object, $row)
  132. {
  133. $selected_objects = TSession::getValue(__CLASS__.'_selected_objects');
  134. if ($selected_objects)
  135. {
  136. if (in_array( (int) $value, array_keys( $selected_objects ) ) )
  137. {
  138. $row->style = "background: #FFD965";
  139. }
  140. }
  141. return $value;
  142. }
  143. /**
  144. * Show selected records
  145. */
  146. public function showResults()
  147. {
  148. $datagrid = new BootstrapDatagridWrapper(new TQuickGrid);
  149. $datagrid->addQuickColumn('Número', 'id', 'right');
  150. $datagrid->addQuickColumn('Nome', 'id_idoso', 'left');
  151. $datagrid->addQuickColumn('Emissão', 'emissao', 'left');
  152. $datagrid->addQuickColumn('UF', 'uf', 'left');
  153. $datagrid->addQuickColumn('Cidade', 'cidade', 'left');
  154. $datagrid->addQuickColumn('Orgao Expedidor', 'orgao_expedidor', 'left');
  155. $datagrid->addQuickColumn('Validade', 'validade', 'left');
  156. // create the datagrid model
  157. $datagrid->createModel();
  158. $selected_objects = TSession::getValue(__CLASS__.'_selected_objects');
  159. ksort($selected_objects);
  160. if ($selected_objects)
  161. {
  162. $datagrid->clear();
  163. foreach ($selected_objects as $selected_object)
  164. {
  165. $datagrid->addItem( (object) $selected_object );
  166. }
  167. }
  168. $win = TWindow::create('Results', 0.6, 0.6);
  169. $win->add($datagrid);
  170. $win->show();
  171. }
  172. }
  173. ?>

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


RS

Vou tentar achar algo.
RS

achei o problema mudei de: TPage para TStandardList e funcionou

 
  1. <?php
  2. class AgetranVagaIdosoSelectionList extends TPage
  3. {
  4. para
  5. class AgetranVagaIdosoSelectionList extends TStandardList
  6. {
  7. ?>