Pagin datagrid problem
| From: | Jandro brozaman | Date: | Tue, 08 May 2007 11:41:36 +0000 |
| Subject: | Pagin datagrid problem | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-27235@lists.php.net to get a copy of this message | ||
Hi all,
I have the following code:
<?php
/************************* Includes ***/
include_once '../common.php';
include_once(CLASSES.'Vr_destination.php');
include_once INC.'common_provinces.inc.php';
include_once INC.'common_tables.inc.php';
/************************* Generate $public ***/
$destiny = new DataObjects_Vr_destination();
if ($_REQUEST['reference'] != "") {
$destiny->whereAdd("reference LIKE '%" .
$destiny->escape($_REQUEST['reference']) . "%'");
}
if ($_REQUEST['destination_type_id'] != 0) {
$destiny->destination_type_id = $_REQUEST['destination_type_id'];
}
$prov = $_REQUEST['zone'][0];
$mun = $_REQUEST['zone'][1];
if ($prov != 0) {
$destiny->province_id = $prov;
}
if ($mun != 0) {
$destiny->town_id = $mun;
}
$destiny->find();
/************************* Generate datagrid ***/
$datagridFields = array (
"destination_id" => "Id",
"reference" => "Referencia",
"name" => "Nombre"
);
$datagrid =& new Structures_DataGrid(30);
$datagrid->generateColumns($datagridFields);
// Add columns
$column1 = new Structures_DataGrid_Column('Tipo destino', null, null,
array('width' => '5%'), null, 'showPublic()', $destinations);
$datagrid->addColumn($column1);
$column2 = new Structures_DataGrid_Column('provincia', null, null, array('width'
=> '5%'), null, 'showProvince()', $provincesArray);
$datagrid->addColumn($column2);
$datagrid->addColumn(new Structures_DataGrid_Column('details', null, null,
array('width' => '5%'), null, 'printEditLink()'));
$datagrid->bind($destiny); // the Magic
if (PEAR::isError($datagrid)) {
echo $datagrid->getMessage();
}
/* Get a reference to the Renderer object */
$renderer =& $datagrid->getRenderer();
/* For the <table> element : */
$renderer->setTableAttribute("class", "fruits");
/* For every odd <tr> elements */
$renderer->setTableOddRowAttributes(array ("class" => "odd"));
/* Get and output HTML links */
$pagingHtml = $renderer->getPaging();
echo "<p class=\"paging\">Páginas : $pagingHtml</p>";
/* Render the table */
$datagrid->render();
echo "<p class=\"paging\">Páginas : $pagingHtml</p>";
/************************* Generate functions ***/
function printEditLink($params) {
extract($params);
return '<a href="edit_destination.php?destination_id=' .
$record['destination_id'] . '">Ver detalle</a>';
}
function showPublic($params, $destinations) {
extract($params);
return $destinations[$record['destination_type_id']];
}
function showProvince($params, $province) {
extract($params);
return $province[$record['province_id']];
}
?>
The application returns all the records right, and paging, but the problem is that it show me all
the records in all the pages not 30 as it should be if my code is right.
My structures_Datagrid version is 0.8.1
I don't know where is the problem. Thank you very much for your help in advanced.
____________________________________________________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com