Home » Structures » Structures_DataGrid » Bug #8392
Handle sorting for multiple tables/page
Details
| Submitted | 2006-08-08 21:45 UTC |
|---|---|
| From | chris dot stone at gmail dot com |
| Assigned | wiesemann |
| Status | Closed |
| Package | Structures_DataGrid |
| PHP Version | 5.1.4 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2006-08-08 21:45 UTC] chris dot stone at gmail dot com
Description:
------------
Sorting does not work properly if you render multiple tables with different table column names on the same page.
Test script:
---------------
<?php
require 'Structures/DataGrid.php';
$d1 = new Structures_DataGrid;
$d2 = new Structures_DataGrid;
$d1->bind('SELECT * FROM table1', array('dsn' => MY_DSN));
$d2->bind('SELECT * FROM table2', array('dsn' => MY_DSN));
$d1->render(); $d2->render();
?>
Expected result:
----------------
Rendering a table with an orderBy GET parameter that does not match any column names in a table should cause the table to be rendered with its default (or most recent) sorting order.
Actual result:
--------------
Rendering a table with an orderBy GET parameter that does not match any column namess in a table causes the table to not be rendered at all.
[2006-08-08 21:47 UTC] chris dot stone at gmail dot com
Description:
------------
Sorting does not work properly if you render multiple tables with different table column names on the same page.
Test script:
---------------
<?php
require 'Structures/DataGrid.php';
$d1 = new Structures_DataGrid;
$d2 = new Structures_DataGrid;
$d1->bind('SELECT * FROM table1', array('dsn' => MY_DSN));
$d2->bind('SELECT * FROM table2', array('dsn' => MY_DSN));
$d1->render();
$d2->render();
?>
Expected result:
----------------
Rendering a table with an orderBy GET parameter that does not match any column names in a table should cause the table to be rendered with its default (or most recent) sorting order.
Actual result:
--------------
Rendering a table with an orderBy GET parameter that does not match any column namess in a table causes the table to not be rendered at all.
[2006-08-09 10:18 UTC] olivierg at php dot net
There is a method for this sort of issue: setRequestPrefix()
Do you know about it?
As you propose, we could try to detect if the orderBy argument contain known columns or not. However, in your example, that would oblige us to perform an additional SQL query. That's too heavy.
[2006-08-09 19:17 UTC] chris dot stone at gmail dot com
I didn't see the setRequestPrefix() method. Perhaps a quick example in the docs on how to handle multiple tables on the same page would be helpful.
This method should be enough to satisfy my problem, so this bug can be closed. Thanks for the info.
[2006-08-09 19:59 UTC] chris dot stone at gmail dot com
I have updated my sample code to the following, but now the sorting links do not work. Is there some extra processing I need to do?
<?php
require 'Structures/DataGrid.php';
$d1 = new Structures_DataGrid;
$d2 = new Structures_DataGrid;
$d1->bind('SELECT * FROM trade', array('dsn' => MY_DSN));
$d2->bind('SELECT * FROM stock', array('dsn' => MY_DSN));
$d1->setRequestPrefix('trade_');
$d2->setRequestPrefix('stock_');
$d1->render();
$d2->render();
?>