Gridconhtmlypager

De CidesaWiki

Saltar a navegación, buscar

Esta explicación funciona para modulos generados con el propel-admin. Este código se encuentra en el módulo "nomjorlablot" de la aplicación de nómina de Siga Software Libre.

	public function executeEdit()
	{
		$c = new Criteria();
		$this->pagerNphojint = NphojintPeer::getPagerByCriteria($c,$this->getRequestParameter('page',1));
		
		parent::executeEdit();
	}

la función NphojintPeer::getPagerByCriteria() fue generada para que hiciera la consulta a la base de datos y retornada el objeto Pager.

        <?php include_partial('nomjorlablot/edit_form', array('npdefjorlab' => $npdefjorlab, 'labels' => $labels, 'pagerNphojint' => $pagerNphojint)) ?>

</fieldset>

<!-- Modifique estas variables y luego coloque las columnas y registros que desee -->
<?php $tituloTabla = __('Datos del Permiso'); ?>
<?php $pagerTabla = $pagerNpfalper; ?>
<?php $modulo = $sf_context->getModuleName(); ?>
<?php $accion = 'edit'; ?>

<fieldset>
<legend><?php echo $tituloTabla; ?></legend>
<table border="0" class="sf_admin_list">
<thead>
	<tr>
		<!-- Nombre de las Columnas -->
	    <th><?php echo NpfalperPeer::getColumName(NpfalperPeer::FECDES ) ?></th>
	    <th><?php echo NpfalperPeer::getColumName(NpfalperPeer::FECHAS )  ?></th>
	    <th><?php echo NpfalperPeer::getColumName(NpfalperPeer::CODMOT )  ?></th>
	    <th><?php echo NpfalperPeer::getColumName(NpmotfalPeer::DESMOTFAL )  ?></th>
	</tr>
</thead>
<tbody>
	<?php $i = 1; foreach ($pagerTabla->getResults() as $registro): $odd = fmod(++$i, 2) ?>
	<tr class="sf_admin_row_<?php echo $odd ?>">
		<!-- Registros de la tabla -->
	    <td><?php echo $registro->getFecdes()  ?></td>
	    <td><?php echo $registro->getFechas() ?></td>
	    <td><?php echo $registro->getCodmot() ?></td>
	    <td><?php echo $registro->getDesmotfal() ?></td>
	</tr>
	<?php endforeach; ?>	
</tbody>

<tfoot>
<tr><th colspan="5">
<div class="float-right">
<?php if ($pagerTabla->haveToPaginate()): ?>
  <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/first.png', array('align' => 'absmiddle', 'alt' => __('First'), 'title' => __('First'))), $modulo.'/'.$accion.'?page=1') ?>
  <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/previous.png', array('align' => 'absmiddle', 'alt' => __('Previous'), 'title' => __('Previous'))), $modulo.'/'.$accion.'?page='.$pagerTabla->getPreviousPage()) ?>

  <?php foreach ($pagerTabla->getLinks() as $page): ?>
    <?php echo link_to_unless($page == $pagerTabla->getPage(), $page, $modulo.'/list?page='.$page) ?>
  <?php endforeach; ?>

	<?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/next.png', array('align' => 'absmiddle', 'alt' => __('Next'), 'title' => __('Next'))), $modulo.'/'.$accion.'?page='.$pagerTabla->getNextPage()) ?>
	<?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/last.png', array('align' => 'absmiddle', 'alt' => __('Last'), 'title' => __('Last'))), $modulo.'/'.$accion.'?page='.$pagerTabla->getLastPage()) ?>
<?php endif; ?>
</div>
<?php echo format_number_choice('[0] '.__('no result').'|[1] 1 '.__('result').'|(1,+Inf] %1% '.__('results'), array('%1%' => $pagerTabla->getNbResults()), $pagerTabla->getNbResults()) ?>
</th></tr>
</tfoot>

</table>
</fieldset>

	const COLUMNS = 'columns';
	
	private static $columsname = array (
	self::COLUMNS => array (NphojintPeer::CEDEMP => 'Cedula', NphojintPeer::NOMEMP => 'Nombre', NphojintPeer::ID =>  'Id', ),);
	
	static public function getColumName($colum)
	{
		return self::$columsname[self::COLUMNS][$colum];
	}
        <td><?php echo checkbox_tag($Nphojint->getId(),'1',false) ?></td>
Herramientas personales
Espacios de nombres
Variantes
Acciones
Navegación
Herramientas