A quick, dirty hack; How to get the columns in the datagrid Sortable with
http://www.frequency-decoder.com/2006/09/16/unobtrusive-table-sort-script-revisited:
The sorting scripts I have found use the structure
<table id="sortedTableID">
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
So in order to get that structure when using this dbEdit-snippet, I had to hack the file
manager/includes/controls/datagrid.class.php:
(Sorry for not using the Code tag here, but colored text is not allowed within that tag, and I wanted to show my changes in red to make them stand out)
----------------------------------------------------
// start grid
$tblStart = "<table
id=’tablesorted’ $cssClass $cssStyle cellpadding=’".(isset($this->cellPadding) ? (int)$this->cellPadding :1)."’ cellspacing=’".(isset($this->cellSpacing) ? (int)$this->cellSpacing:1)."’>";
$tblEnd = "
</tbody>\n</table>";
// build column header
$this->_colnames = explode((strstr($this->columns,"||")!==false ? "||":","),$this->columns);
$this->_colwidths = explode((strstr($this->colWidths,"||")!==false ? "||":","),$this->colWidths);
$this->_colaligns = explode((strstr($this->colAligns,"||")!==false ? "||":","),$this->colAligns);
$this->_colwraps = explode((strstr($this->colWraps,"||")!==false ? "||":","),$this->colWraps);
$this->_colcolors = explode((strstr($this->colColors,"||")!==false ? "||":","),$this->colColors);
$this->_coltypes = explode((strstr($this->colTypes,"||")!==false ? "||":","),$this->colTypes);
$this->_colcount = count($this->_colnames);
if(!$this->_isDataset) {
$this->ds = explode((strstr($this->ds,"||")!==false ? "||":","),$this->ds);
$this->ds = array_chunk($this->ds, $this->_colcount);
}
$tblColHdr ="<thead>\n<tr>";
for($c=0;$c<$this->_colcount;$c++){
$name=$this->_colnames[$c];
$width=$this->_colwidths[$c];
$tblColHdr.="
<th class=’sortable’ $columnHeaderStyle $columnHeaderClass".($width? " width=’$width’":"").">$name
</th>";
}
$tblColHdr.="</tr>\n
</thead>\n<tbody>\n\n";
----------------------------------------------------
The code it self is not changed, I have only added/changed some output tags.
Next, in
assets/modules/dbedit/records.list.records.inc.php I added:
-----------------------------------------------------
<td ><a href="#" class="searchbutton" title="Search" onclick="filterGrid();return false;">Go</a></td>
<?php if(isset($dbConfig[’deletedField’]) ){ ?>
<td><a class="searchtoolbarbtn" href="<?php echo $dbeHomeUrl; ?>&ra=opentrash"><img src="media/style/<?php echo $manager_theme; ?>images/tree/trash.gif" width="16" height="16" align="absmiddle" /> Trash Bin</a></td>
<?php } ?>
</tr>
</table>
</td>
</tr>
</table>
</div>
<script type="text/javascript" src="media/script/mootools/sortableTable.js"></script> (This is the unobtrusive-table-sort-script from above)
<link href="../css/tablesort.css" rel="stylesheet" type="text/css" /> (This is just for giving my Table some style)
<?php echo $grid_html; ?>
</div>
-------------------------------------------------------