Lançado Adianti Framework 7.6!
Clique aqui para saber mais
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.     /**
  9.      * Class constructor
  10.      * Creates the page, the form and the listing
  11.      */
  12.     public function __construct()
  13.     {
  14.         parent::__construct();
  15.         
  16.         new TSession;
  17.         
  18.         // defines the database
  19.         parent::setDatabase('mysql');
  20.         
  21.         // defines the active record
  22.         parent::setActiveRecord('Cargos');
  23.         
  24.         // define the filter field
  25.         parent::setFilterField('nome');
  26.         
  27.         // creates the form
  28.         $this->form = new TForm('form_search_produto');
  29.         
  30.         // creates a table
  31.         $table = new TTable;
  32.         
  33.         // add the table inside the form
  34.         $this->form->add($table);
  35.         
  36.         // create the form fields
  37.         $name = new TEntry('nome');
  38.         $name->setValue(TSession::getValue('nome'));
  39.         
  40.         // add a row for the field name
  41.         $row=$table->addRow();
  42.         $row->addCell(new TLabel('Name:'));
  43.         $row->addCell($name);
  44.         
  45.         // create two action buttons to the form
  46.         $find_button = new TButton('find');
  47.         $new_button  = new TButton('new');
  48.         // define the button actions
  49.         $find_button->setAction(new TAction(array($this'onSearch')), 'Find');
  50.         $find_button->setImage('ico_find.png');
  51.         
  52.         $new_button->setAction(new TAction(array('frmCargo''onEdit')), 'New');
  53.         $new_button->setImage('ico_new.png');
  54.         
  55.         // add a row for the form actions
  56.         $row=$table->addRow();
  57.         $row->addCell($find_button);
  58.         $row->addCell($new_button);
  59.         
  60.         // define wich are the form fields
  61.         $this->form->setFields(array($name$find_button$new_button));
  62.         
  63.         // creates a DataGrid
  64.         $this->datagrid = new TQuickGrid;
  65.         $this->datagrid->setHeight(230);
  66.         // creates the datagrid columns
  67.         $this->datagrid->addQuickColumn('id''id''right'40, new TAction(array($this'onReload')), array('order''id'));
  68.        $this->datagrid->addQuickColumn('name''nome''left'250, new TAction(array($this'onReload')), array('order''name'));
  69.         $this->datagrid->addQuickColumn('Descricao''descricao''right',200);
  70.          $this->datagrid->addQuickColumn('Salario''salario''right'200);
  71.           $this->datagrid->addQuickColumn('Setor''setor''right'200);
  72.         // creates two datagrid actions
  73.         $this->datagrid->addQuickAction('Edit', new TDataGridAction(array('frmCargo''onEdit')), 'id''ico_edit.png');
  74.         $this->datagrid->addQuickAction('Delete', new TDataGridAction(array($this'onDelete')), 'id''ico_delete.png');
  75.         
  76.      
  77.         // create the datagrid model
  78.         $this->datagrid->createModel();
  79.         
  80.         // creates the page navigation
  81.         $this->pageNavigation = new TPageNavigation;
  82.         $this->pageNavigation->setAction(new TAction(array($this'onReload')));
  83.         $this->pageNavigation->setWidth($this->datagrid->getWidth());
  84.         
  85.         // creates the page structure using a table
  86.         $table = new TTable;
  87.         $table->addRow()->addCell($this->form);
  88.         $table->addRow()->addCell($this->datagrid);
  89.         $table->addRow()->addCell($this->pageNavigation);
  90.         
  91.         // add the table inside the page
  92.         parent::add($table);
  93.     }
  94. }
  95. ?>


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

Pacotão Dominando o Adianti Framework 7
O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado! Versão 7.4


Dominando o Adianti 7 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