Home > Archive > PHP Pear > May 2006 > Datagrid - possible bug (paging / sorting)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Datagrid - possible bug (paging / sorting)
|
|
|
| Hi,
i more or less took the example by Olivier
(http://www.samalyse.com/code/pear/dgdo/),
to get a quick look at Datagrid.
I am using the following source (with the current cvs version of datagrid).
when i now click on one of the column headers datagrid should sort the
table, but instead of sorting it just jumps back to page1.
am i doing something wrong.. or is it a bug?
greetings,
Toppi
---
<style type="text/css">
body {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 11px;
}
table.standard {
border-left: solid 1px #990033;
border-top: solid 1px #990033;
border-bottom: solid 1px #990033;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 11px;
border-collapse: collapse;
width: 36em;
margin-left: 1em;
}
table.standard th {
text-align: center;
border-right: solid 1px #990033;
border-bottom: solid 1px #990033;
background: #990033;
padding: 2px;
color: white;
padding-left: 1em;
padding-right: 1em;
}
table.standard th a {
color: white;
text-decoration: none;
}
table.standard th a:hover {
color: #EEEEEE;
}
table.standard td {
text-align: right;
border-right: solid 1px #990033;
padding: 2px;
}
table.standard tr.odd {
background: #F4F4F4;
}
p.paging {
text-align: center;
font-weight: bold;
}
p.paging a {
color: #990033;
}
</style>
<?php
require 'Structures/DataGrid.php';
// 10 records per page
$datagrid =& new Structures_DataGrid(10);
// Setup your datasource
$options = array('dsn' =>
'mysql://root:pass123@127.0.0.1/information_schema');
$test = $datagrid->bind("SELECT * FROM STATISTICS", $options, "DBQuery");
if (PEAR::isError($test)) {
echo $test->getMessage();
}
/*
// Print the DataGrid with the default renderer (HTML Table)
$test = $datagrid->render();
if (PEAR::isError($test)) {
echo $test->getMessage();
}
// Print the HTML paging links
$test = $datagrid->render(DATAGRID_RENDER_PAGER);
if (PEAR::isError($test)) {
echo $test->getMessage();
}
*/
$renderer =& $datagrid->getRenderer();
/* For the <table> element : */
$renderer->setTableAttribute("class", "standard");
/* For every odd <tr> elements */
$renderer->setTableOddRowAttributes(array ("class" => "odd"));
$pagingHtml = $renderer->getPaging();
echo "<p class=\"paging\">Pages : $pagingHtml</p>";
$datagrid->render();
?>
---
..
| |
| Mark Wiesemann 2006-05-23, 4:01 am |
| Toppi wrote:
> i more or less took the example by Olivier
> (http://www.samalyse.com/code/pear/dgdo/),
> to get a quick look at Datagrid.
>
> I am using the following source (with the current cvs version of datagrid).
>
> when i now click on one of the column headers datagrid should sort the
> table, but instead of sorting it just jumps back to page1.
The jumping is a 'feature', your table should also be sorted.
I'm short in time currently -- therefore, please have a look at the
source of Renderer/HTMLTable.php and the rendering option
'sortingResetsPaging' that is described there. If you disable this
option, the jumping won't occur anymore.
Regards,
Mark
|
|
|
|
|