Duplicata TDBGrid galeta estou com o sguinte codigo ...
AS
Duplicata TDBGrid  
Fechado
galeta estou com o sguinte codigo


 
  1. <?php
  2. class CargosView extends TStandardList
  3. {
  4. protected $form; // registration form
  5. protected $datagrid; // listing
  6. protected $pageNavigation;
  7. /**
  8. * Class constructor
  9. * Creates the page, the form and the listing
  10. */
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. new TSession;
  15. // defines the database
  16. parent::setDatabase('mysql');
  17. // defines the active record
  18. parent::setActiveRecord('Cargos');
  19. // define the filter field
  20. parent::setFilterField('nome');
  21. // creates the form
  22. $this->form = new TForm('form_search_produto');
  23. // creates a table
  24. $table = new TTable;
  25. // add the table inside the form
  26. $this->form->add($table);
  27. // create the form fields
  28. $name = new TEntry('nome');
  29. $name->setValue(TSession::getValue('nome'));
  30. // add a row for the field name
  31. $row=$table->addRow();
  32. $row->addCell(new TLabel('Name:'));
  33. $row->addCell($name);
  34. // create two action buttons to the form
  35. $find_button = new TButton('find');
  36. $new_button = new TButton('new');
  37. // define the button actions
  38. $find_button->setAction(new TAction(array($this, 'onSearch')), 'Find');
  39. $find_button->setImage('ico_find.png');
  40. $new_button->setAction(new TAction(array('frmCargo', 'onEdit')), 'New');
  41. $new_button->setImage('ico_new.png');
  42. // add a row for the form actions
  43. $row=$table->addRow();
  44. $row->addCell($find_button);
  45. $row->addCell($new_button);
  46. // define wich are the form fields
  47. $this->form->setFields(array($name, $find_button, $new_button));
  48. // creates a DataGrid
  49. $this->datagrid = new TQuickGrid;
  50. $this->datagrid->setHeight(230);
  51. // creates the datagrid columns
  52. $this->datagrid->addQuickColumn('id', 'id', 'right', 40, new TAction(array($this, 'onReload')), array('order', 'id'));
  53. $this->datagrid->addQuickColumn('name', 'nome', 'left', 250, new TAction(array($this, 'onReload')), array('order', 'name'));
  54. $this->datagrid->addQuickColumn('Descricao', 'descricao', 'right',200);
  55. $this->datagrid->addQuickColumn('Salario', 'salario', 'right', 200);
  56. $this->datagrid->addQuickColumn('Setor', 'setor', 'right', 200);
  57. // creates two datagrid actions
  58. $this->datagrid->addQuickAction('Edit', new TDataGridAction(array('frmCargo', 'onEdit')), 'id', 'ico_edit.png');
  59. $this->datagrid->addQuickAction('Delete', new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
  60. // create the datagrid model
  61. $this->datagrid->createModel();
  62. // creates the page navigation
  63. $this->pageNavigation = new TPageNavigation;
  64. $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
  65. $this->pageNavigation->setWidth($this->datagrid->getWidth());
  66. // creates the page structure using a table
  67. $table = new TTable;
  68. $table->addRow()->addCell($this->form);
  69. $table->addRow()->addCell($this->datagrid);
  70. $table->addRow()->addCell($this->pageNavigation);
  71. // add the table inside the page
  72. parent::add($table);
  73. }
  74. }
  75. ?>


porem quando clico no topo da coluna data para ordernar ele duplica todos os reistros, aguem tem algiuma ideia do pq?

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


PD

Oi Alexandre,

Não tem uma coluna chamada "data" nesse código.
Além disso, nada justificaria exibir registros em duplicidade, a não ser que assim eles estão no banco de dados...

Pablo