AS
Duplicata TDBGrid
Fechado
galeta estou com o sguinte codigo
porem quando clico no topo da coluna data para ordernar ele duplica todos os reistros, aguem tem algiuma ideia do pq?
- <?php
- class CargosView extends TStandardList
- {
- protected $form; // registration form
- protected $datagrid; // listing
- protected $pageNavigation;
- /**
- * Class constructor
- * Creates the page, the form and the listing
- */
- public function __construct()
- {
- parent::__construct();
- new TSession;
- // defines the database
- parent::setDatabase('mysql');
- // defines the active record
- parent::setActiveRecord('Cargos');
- // define the filter field
- parent::setFilterField('nome');
- // creates the form
- $this->form = new TForm('form_search_produto');
- // creates a table
- $table = new TTable;
- // add the table inside the form
- $this->form->add($table);
- // create the form fields
- $name = new TEntry('nome');
- $name->setValue(TSession::getValue('nome'));
- // add a row for the field name
- $row=$table->addRow();
- $row->addCell(new TLabel('Name:'));
- $row->addCell($name);
- // create two action buttons to the form
- $find_button = new TButton('find');
- $new_button = new TButton('new');
- // define the button actions
- $find_button->setAction(new TAction(array($this, 'onSearch')), 'Find');
- $find_button->setImage('ico_find.png');
- $new_button->setAction(new TAction(array('frmCargo', 'onEdit')), 'New');
- $new_button->setImage('ico_new.png');
- // add a row for the form actions
- $row=$table->addRow();
- $row->addCell($find_button);
- $row->addCell($new_button);
- // define wich are the form fields
- $this->form->setFields(array($name, $find_button, $new_button));
- // creates a DataGrid
- $this->datagrid = new TQuickGrid;
- $this->datagrid->setHeight(230);
- // creates the datagrid columns
- $this->datagrid->addQuickColumn('id', 'id', 'right', 40, new TAction(array($this, 'onReload')), array('order', 'id'));
- $this->datagrid->addQuickColumn('name', 'nome', 'left', 250, new TAction(array($this, 'onReload')), array('order', 'name'));
- $this->datagrid->addQuickColumn('Descricao', 'descricao', 'right',200);
- $this->datagrid->addQuickColumn('Salario', 'salario', 'right', 200);
- $this->datagrid->addQuickColumn('Setor', 'setor', 'right', 200);
- // creates two datagrid actions
- $this->datagrid->addQuickAction('Edit', new TDataGridAction(array('frmCargo', 'onEdit')), 'id', 'ico_edit.png');
- $this->datagrid->addQuickAction('Delete', new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
- // create the datagrid model
- $this->datagrid->createModel();
- // creates the page navigation
- $this->pageNavigation = new TPageNavigation;
- $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
- $this->pageNavigation->setWidth($this->datagrid->getWidth());
- // creates the page structure using a table
- $table = new TTable;
- $table->addRow()->addCell($this->form);
- $table->addRow()->addCell($this->datagrid);
- $table->addRow()->addCell($this->pageNavigation);
- // add the table inside the page
- parent::add($table);
- }
- }
- ?>
porem quando clico no topo da coluna data para ordernar ele duplica todos os reistros, aguem tem algiuma ideia do pq?
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