PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Structures » Structures_DataGrid » Bug #7150

Sorting tabular structure doesn't work

Details

Submitted2006-03-18 11:18 UTC
FromPEZf68 at gmail dot com
Assignedolivierg
StatusClosed
PackageStructures_DataGrid
PHP Version5.1.2
OSWindows 2000/ Windows XP
Roadmaps(Not assigned)

Comments

[2006-03-18 11:18 UTC] PEZf68 at gmail dot com

Description:
------------
When trying to sort a table generated by Structure_DataGrid (from a DB_Result Object), it doesn't work. $_GET parameters are displayed but the table isn't affected when clicking on the orderBy fields.

After several tests on various configurations , it seems it can't work only with the last PHP version (5.1.2) (Other versions work fine)

Test script:
---------------
$grille =& new Structures_DataGrid(10);
$grille->sortRecordSet($orderBy, $dir);

if ($liste_admin->numRows() Aucun résultat trouvé';
$pagingHtml = "";

}else{

$grille->bind($liste_admin);
$grille->addColumn(new Structures_DataGrid_Column('Login', null, 'login_admin', array(), null, 'afficheLoginAdmin()'));
$grille->addColumn(new Structures_DataGrid_Column('Mail', null, 'mail_admin', array(), null, 'afficheMailAdmin()'));
$grille->addColumn(new Structures_DataGrid_Column('Fonction', null, 'libelle_fonction', array(), null, 'afficheFonctionAdmin()'));
$grille->addColumn(new Structures_DataGrid_Column('Actif', null, 'actif_admin', array(), null, 'afficheActifAdmin()'));
$grille->addColumn(new Structures_DataGrid_Column('Actions', null, null, array(), null, 'afficheActionsAdmin()'));

$renderer =& $grille->getRenderer();
$pagingHtml = $renderer->getPaging(); //creation de la pagination
$pagingHtml = ''.$pagingHtml.'';
$renderer->setTableAttribute("class", "ftable");
$renderer->setTableAttribute('width', '100%');
$renderer->setTableAttribute('cellspacing', '0');
$renderer->setTableAttribute('cellpadding', '5');
$test = $renderer->toHTML();

}
$contenu .= $test;
$contenu .= $pagingHtml;

[2006-03-18 16:24 UTC] olivierg at php dot net

Your script doesn't work in both PHP4 and PHP5 when register_globals is turned off. You need to remove this line :
$grille->sortRecordSet($orderBy, $dir);

It isn't needed to call sortRecordSet(). The GET parameters are automatically handled, and the DataSource::sort() method called accordingly.

However your script would work if you called :
$grille->sortRecordSet($_GET['orderBy'], $_GET['direction']);

But once again you don't need to call sortRecordSet() in this case.

This behaviour has nothing to do with the PHP version, but with the value of the register_globals option and your incorrect use of the sortRecordSet() method.

This is no bug.

[2006-03-18 16:52 UTC] PEZf68 at gmail dot com

Thanks for your answer.

Actually, both $orderBy and $dir variables are setted before calling sortRecordSet() :

$orderBy = isset($_GET['orderBy']) ? $_GET['orderBy'] : 'login_admin';
$dir = isset($_GET['direction']) ? $_GET['direction'] : 'ASC';

and register_global is turned off.

I also tried my script after removing sortRecordSet() and it still doesn't sort the table.

[2006-03-18 17:11 UTC] olivierg at php dot net

Okay sorry... I double-checked, and, even without sortRecordSet(), your script doesn't work with SDG 0.6.3 under PHP 5.1.2.

This is a bug.

But, for some obscure reasons, the CVS is not affected by this bug. So this bug is fixed in CVS.... You can use the CVS version or wait a few weeks for the next release that should be online between the end of march and the middle of april.

Please post full test scripts with your bugs in the future.

Thank you for your report.