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


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

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