Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Paginação Default boa noite galera, estou usando o seguinte codigo ...
AS
Paginação Default  
Fechado
boa noite galera, estou usando o seguinte codigo


  1. <?php 
  2. /** class de controle de funcionarios
  3. * author Alexandre E. Souza
  4. */
  5. class FornecedorView extends TStandardList{
  6.     
  7.    protected $form;     // registration form
  8.     protected $datagrid// listing
  9.     protected $pageNavigation;
  10.     
  11.     /**
  12.      * Class constructor
  13.      * Creates the page, the form and the listing
  14.      */
  15.     public function __construct()
  16.     {
  17.         parent::__construct();
  18.         
  19.         new TSession;
  20.         
  21.         // defines the database
  22.         parent::setDatabase('mysql');
  23.         
  24.         // defines the active record
  25.         parent::setActiveRecord('Fornecedor');
  26.         
  27.         // define the filter field
  28.         parent::setFilterField('razaoSocial');
  29.         
  30.         // creates the form
  31.         $this->form = new TForm('form_search_produto');
  32.         
  33.         // creates a table
  34.         $table = new TTable;
  35.         
  36.         // add the table inside the form
  37.         $this->form->add($table);
  38.         
  39.         // create the form fields
  40.         $name = new TEntry('razaoSocial');
  41.         $name->setValue(TSession::getValue('razaoSocial'));
  42.         
  43.         // add a row for the field name
  44.         $row=$table->addRow();
  45.         $row->addCell(new TLabel('Razão Social:'));
  46.         $row->addCell($name);
  47.         
  48.         // create two action buttons to the form
  49.         $find_button = new TButton('find');
  50.         $new_button  = new TButton('new');
  51.         // define the button actions
  52.         $find_button->setAction(new TAction(array($this'onSearch')), 'Find');
  53.         $find_button->setImage('ico_find.png');
  54.         
  55.         $new_button->setAction(new TAction(array('frmFornecedor''onEdit')), 'New');
  56.         $new_button->setImage('ico_new.png');
  57.         
  58.         // add a row for the form actions
  59.         $row=$table->addRow();
  60.         $row->addCell($find_button);
  61.         $row->addCell($new_button);
  62.         
  63.         // define wich are the form fields
  64.         $this->form->setFields(array($name$find_button$new_button));
  65.         
  66.         // creates a DataGrid
  67.         $this->datagrid = new TQuickGrid;
  68.         $this->datagrid->setHeight(230);
  69.         // creates the datagrid columns
  70.         $this->datagrid->addQuickColumn('id''id''right'40, new TAction(array($this'onReload')), array('order''id'));
  71.        $this->datagrid->addQuickColumn('Razão Social''razaoSocial''left'250, new TAction(array($this'onReload')), array('order''razaoSocial'));
  72.         $this->datagrid->addQuickColumn('Responsavel''responsavel''right',100);
  73.          $this->datagrid->addQuickColumn('Telefone''telefone''right'100);
  74.           $this->datagrid->addQuickColumn('Cidade''cidade''right'100);
  75.           $this->datagrid->addQuickColumn('Bairro''bairro''right'100);
  76.           $this->datagrid->addQuickColumn('Rua''rua''right'100);
  77.         // creates two datagrid actions
  78.         $this->datagrid->addQuickAction('Edit', new TDataGridAction(array('frmFornecedor''onEdit')), 'id''ico_edit.png');
  79.         $this->datagrid->addQuickAction('Delete', new TDataGridAction(array($this'onDelete')), 'id''ico_delete.png');
  80.         
  81.      
  82.         // create the datagrid model
  83.         $this->datagrid->createModel();
  84.         
  85.         // creates the page navigation
  86.         $this->pageNavigation = new TPageNavigation;
  87.         $this->pageNavigation->setAction(new TAction(array($this'onReload')));
  88.         $this->pageNavigation->setWidth($this->datagrid->getWidth());
  89.         
  90.         // creates the page structure using a table
  91.         $table = new TTable;
  92.         $table->addRow()->addCell($this->form);
  93.         $table->addRow()->addCell($this->datagrid);
  94.         $table->addRow()->addCell($this->pageNavigation);
  95.         
  96.         // add the table inside the page
  97.         parent::add($table);
  98.     }
  99. }
  100. ?>


vi esse codigo no tutor mantive ate os comentarios
essa paginação default dele aparece depois de quantos registros?

Curso completo Meu Negócio Pronto
Use para si, ou transforme em um negócio: Inclui aulas e códigos-fontes
Gestor de conteúdo (SITE) + Loja Virtual (E-Commerce) + Emissor de Notas para infoprodutos


Meu negócio pronto Quero me inscrever agora!

Comentários (4)


PD

Oi Alexandre,

Veja no código da TStandardList, que são 10:
www.adianti.com.br/api-framework-control-TStandardList#onReload

Mas você pode configurar por meio do setLimit():
www.adianti.com.br/api-framework-control-TStandardList#setLimit

abs,
Pablo
AS

vlw pablo
RK

Pablo,

Em uma listagem estou tentando definir o limite de registros por página com o método <? setLimit(30); ?> porém sem sucesso, a página segue sendo gerada com o limite padrão (10 registros).
Segue abaixo o código (vide linha 128):

  1. <?php
  1. <?php
  2. /**
  3.  * AtorList Listing
  4.  * @author  <your name here>
  5.  */
  6. class AtorList extends TStandardList
  7. {
  8.     protected $form;     // registration form
  9.     protected $datagrid// listing
  10.     protected $pageNavigation;
  11.     protected $formgrid;
  12.     protected $deleteButton;
  13.     protected $transformCallback;
  14.     
  15.     /**
  16.      * Page constructor
  17.      */
  18.     public function __construct()
  19.     {
  20.         parent::__construct();
  21.         
  22.         parent::setDatabase('mysql');            // defines the database
  23.         parent::setActiveRecord('Ator');   // defines the active record
  24.         parent::setDefaultOrder('id''asc');         // defines the default order
  25.         // parent::setCriteria($criteria) // define a standard filter
  26.         parent::addFilterField('id''=''id'); // filterField, operator, formField
  27.         parent::addFilterField('nome''like''nome'); // filterField, operator, formField
  28.         
  29.         // creates the form
  30.         $this->form = new TQuickForm('form_search_Ator');
  31.         $this->form->class 'tform'// change CSS class
  32.         
  33.         $this->form->style 'display: table;width:100%'// change style
  34.         $this->form->setFormTitle('Atores cadastrados');
  35.         
  36.         // create the form fields
  37.         $id = new TEntry('id');
  38.         $nome = new TEntry('nome');
  39.         // add the fields
  40.         $this->form->addQuickField('Id'$id,  70 );
  41.         $this->form->addQuickField('Nome'$nome,  300 );
  42.         
  43.         // keep the form filled during navigation with session data
  44.         $this->form->setDataTSession::getValue('Ator_filter_data') );
  45.         
  46.         // add the search form actions
  47.         $this->form->addQuickAction(_t('Find'), new TAction(array($this'onSearch')), 'fa:search');
  48.         $this->form->addQuickAction(_t('New'),  new TAction(array('AtorForm''onEdit')), 'bs:plus-sign green');
  49.         
  50.         // creates a DataGrid
  51.         $this->datagrid = new TDataGrid;
  52.        
  53.         $this->datagrid->style 'width: 100%';
  54.         $this->datagrid->setHeight(320);
  55.         // $this->datagrid->datatable = 'true';
  56.         // $this->datagrid->enablePopover('Popover', 'Hi <b> {name} </b>');
  57.         
  58.         // creates the datagrid columns
  59.         $column_id = new TDataGridColumn('id''Id''center');
  60.         $column_nome = new TDataGridColumn('nome''Nome''left');
  61.         $column_nome_real = new TDataGridColumn('nome_real''Nome real''left');
  62.         $column_dt_nascimento = new TDataGridColumn('dt_nascimento''Nascimento''center');
  63.         // add the columns to the DataGrid
  64.         $this->datagrid->addColumn($column_id);
  65.         $this->datagrid->addColumn($column_nome);
  66.         $this->datagrid->addColumn($column_nome_real);
  67.         $this->datagrid->addColumn($column_dt_nascimento);
  68.         // creates the datagrid column actions
  69.         $order_id = new TAction(array($this'onReload'));
  70.         $order_id->setParameter('order''id');
  71.         $column_id->setAction($order_id);
  72.         
  73.         $order_nome = new TAction(array($this'onReload'));
  74.         $order_nome->setParameter('order''nome');
  75.         $column_nome->setAction($order_nome);
  76.         
  77.         $order_nome_real = new TAction(array($this'onReload'));
  78.         $order_nome_real->setParameter('order''nome_real');
  79.         $column_nome_real->setAction($order_nome_real);
  80.         
  81.         $order_dt_nascimento = new TAction(array($this'onReload'));
  82.         $order_dt_nascimento->setParameter('order''dt_nascimento');
  83.         $column_dt_nascimento->setAction($order_dt_nascimento);
  84.         // define the transformer method over image
  85.         $column_dt_nascimento->setTransformer( function($value$object$row) {
  86.             $date = new DateTime($value);
  87.             return $date->format('d/m/Y');
  88.         });
  89.         
  90.         // create EDIT action
  91.         $action_edit = new TDataGridAction(array('AtorForm''onEdit'));
  92.         $action_edit->setUseButton(TRUE);
  93.         $action_edit->setButtonClass('btn btn-default');
  94.         //$action_edit->setLabel(_t('Edit'));
  95.         $action_edit->setImage('fa:pencil-square-o blue fa-lg');
  96.         $action_edit->setField('id');
  97.         $this->datagrid->addAction($action_edit);
  98.         
  99.         // create DELETE action
  100.         $action_del = new TDataGridAction(array($this'onDelete'));
  101.         $action_del->setUseButton(TRUE);
  102.         $action_del->setButtonClass('btn btn-default');
  103.         //$action_del->setLabel(_t('Delete'));
  104.         $action_del->setImage('fa:trash-o red fa-lg');
  105.         $action_del->setField('id');
  106.         $this->datagrid->addAction($action_del);
  107.         
  108.         // create the datagrid model
  109.         $this->datagrid->createModel();
  110.         
  111.         // create the page navigation
  112.         $this->pageNavigation = new TPageNavigation;
  113.         $this->pageNavigation->setAction(new TAction(array($this'onReload')));
  114.         $this->pageNavigation->setWidth($this->datagrid->getWidth());
  115.         $this->pageNavigation->setLimit(30);
  116.                 
  117.         // vertical box container
  118.         $container = new TVBox;
  119.         $container->style 'width: 90%';
  120.         //$container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  121.         $container->add($this->form);
  122.         $container->add($this->datagrid);
  123.         $container->add($this->pageNavigation);
  124.         
  125.         parent::add($container);
  126.     }
  127.     
  128. }
  129. ?>
</your>
DC

no codigo acima a classe AtorList estende TStandardList e a paginação vem de TStandardList por isso deve ser usado o comando parent::setLimit(30);