Formulário de Edição não sendo vinculado ao id específico banco de dados mysql, não consigo fazer a edição buscando pelo id na datagrid ...
HL
Formulário de Edição não sendo vinculado ao id específico  
banco de dados mysql, não consigo fazer a edição buscando pelo id na datagrid

 
  1. <?php
  2. /**
  3. * GrupoList
  4. *
  5. * @version 1.0
  6. * @package erphouse
  7. * @subpackage control
  8. * @author Pablo Dall'Oglio
  9. * @copyright Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  10. * @license http://www.adianti.com.br/framework-license
  11. */
  12. class GrupoList extends TPage
  13. {
  14. protected $form; // registration form
  15. protected $datagrid; // listing
  16. protected $pageNavigation;
  17. protected $formgrid;
  18. protected $deleteButton;
  19. use Adianti\base\AdiantiStandardListTrait;
  20. /**
  21. * Page constructor
  22. */
  23. public function __construct()
  24. {
  25. parent::__construct();
  26. $this->setDatabase('sys_db'); // defines the database
  27. $this->setActiveRecord('Grupo'); // defines the active record
  28. $this->setDefaultOrder('id', 'asc'); // defines the default order
  29. $this->setLimit(10);
  30. // $this->setCriteria($criteria) // define a standard filter
  31. $this->addFilterField('id', '=', 'id'); // filterField, operator, formField
  32. $this->addFilterField('no_nome', 'like', 'no_nome'); // filterField, operator, formField
  33. // creates the form
  34. $this->form = new BootstrapFormBuilder('form_search_Grupo');
  35. $this->form->setFormTitle('Grupo');
  36. // create the form fields
  37. $id = new TEntry('id');
  38. $nome = new TEntry('no_nome');
  39. // add the fields
  40. $this->form->addFields( [ new TLabel('Id') ], [ $id ] );
  41. $this->form->addFields( [ new TLabel('Nome') ], [ $nome ] );
  42. // set sizes
  43. $id->setSize('100%');
  44. $nome->setSize('100%');
  45. // keep the form filled during navigation with session data
  46. $this->form->setData( TSession::getValue(__CLASS__.'_filter_data') );
  47. // add the search form actions
  48. $btn = $this->form->addAction(_t('Find'), new TAction([$this, 'onSearch']), 'fa:search');
  49. $btn->class = 'btn btn-sm btn-primary';
  50. $this->form->addActionLink(_t('New'), new TAction(['GrupoForm', 'onEdit'], ['register_state' => 'false']), 'fa:plus green');
  51. // creates a Datagrid
  52. $this->datagrid = new BootstrapDatagridWrapper(new TDataGrid);
  53. $this->datagrid->style = 'width: 100%';
  54. //$this->datagrid->datatable = 'true';
  55. // $this->datagrid->enablePopover('Popover', 'Hi <b> {name} </b>');
  56. // creates the datagrid columns
  57. $column_id = new TDataGridColumn('id', 'Id', 'center', '10%');
  58. $column_nome = new TDataGridColumn('no_nome', 'Nome', 'left');
  59. // add the columns to the DataGrid
  60. $this->datagrid->addColumn($column_id);
  61. $this->datagrid->addColumn($column_nome);
  62. // creates the datagrid column actions
  63. $column_id->setAction(new TAction([$this, 'onReload']), ['order' => 'id']);
  64. $column_nome->setAction(new TAction([$this, 'onReload']), ['order' => 'no_nome']);
  65. $action1 = new TDataGridAction(['GrupoForm', 'onEdit'], ['id'=>'{id}', 'register_state' => 'false']);
  66. $action2 = new TDataGridAction([$this, 'onDelete'], ['id'=>'{id}']);
  67. $this->datagrid->addAction($action1, _t('Edit'), 'far:edit blue');
  68. $this->datagrid->addAction($action2 ,_t('Delete'), 'far:trash-alt red');
  69. // create the datagrid model
  70. $this->datagrid->createModel();
  71. // creates the page navigation
  72. $this->pageNavigation = new TPageNavigation;
  73. $this->pageNavigation->setAction(new TAction([$this, 'onReload']));
  74. $panel = new TPanelGroup('', 'white');
  75. $panel->add($this->datagrid);
  76. $panel->addFooter($this->pageNavigation);
  77. // header actions
  78. $dropdown = new TDropDown(_t('Export'), 'fa:list');
  79. $dropdown->setPullSide('right');
  80. $dropdown->setButtonClass('btn btn-info waves-effect dropdown-toggle');
  81. $dropdown->addAction( _t('Save as CSV'), new TAction([$this, 'onExportCSV'], ['register_state' => 'false', 'static'=>'1']), 'fa:table blue' );
  82. $dropdown->addAction( _t('Save as PDF'), new TAction([$this, 'onExportPDF'], ['register_state' => 'false', 'static'=>'1']), 'far:file-pdf red' );
  83. $panel->addHeaderWidget( $dropdown );
  84. // vertical box container
  85. $container = new TVBox;
  86. $container->style = 'width: 100%';
  87. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  88. $container->add($this->form);
  89. $container->add($panel);
  90. parent::add($container);
  91. }
  92. }

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)


NR

Se entendi, ao clicar para editar um item da grid o formulário não carrega as informações. É isso?

Normalmente a função onEdit utiliza o parâmetro "key" para identificar o id do registro. Aparentemente você está informando somente o parâmetro "id".
HL

já resolvir, o problema era forma que que modelei o banco de dados