diff --git a/etemplate/doc/reference.html b/etemplate/doc/reference.html index 14ac8bd28f..084ba3df85 100644 --- a/etemplate/doc/reference.html +++ b/etemplate/doc/reference.html @@ -786,10 +786,6 @@ function get_rows($query,&$rows,&$readonlys) { $rows = array( ); } - else - { - array_unshift($rows,0); each($rows); // first entry is not used !!! - } $readonlys = array( ); // set readonlys to enable/disable our edit/delete-buttons while (list($n,$note) = each($rows)) { @@ -846,9 +842,9 @@ function index($content = 0) - Nextmatch-
SortHeader

Nextmatch-
FilterHeader
+ Nextmatch-
SortHeader

Nextmatch-
FilterHeader

Nextmatch-
AccountFilter
- <nextmatch type="nextmatch-sortheader" id="col-name" label="ColLabel"/>

+ <nextmatch type="nextmatch-sortheader" id="col-name" options="DESC" label="ColLabel"/>

<nextmatch type="nextmatch-filterheader" id="col-name"/>

<nextmatch type="nextmatch-accountfilter" id="col-name"/> @@ -859,7 +855,8 @@ function index($content = 0) nextmatch-sortheader
Widget to be placed as a colum-header in the headerline of a nextmatch-template. It allows, by clicking on it, to order the lines of the nextmatch after a certain column. The column-name is given as name (xml:id) the - label is show as a link of button (no javascript). Consecutive click on the header change the sorting + label is show as a link of button (no javascript). One can specify a default sorting: options={DESC|ASC} (default=ASC), + to be used when the header is clicked for the first time. Consecutive click on the header change the sorting direction, indicated by a little up- or down-arrow.

nextmatch-filterheader
Widget to allow to show only certain row, which match a selected filter-value. The column-name is given as name diff --git a/etemplate/inc/class.nextmatch_widget.inc.php b/etemplate/inc/class.nextmatch_widget.inc.php index c775816075..502d81298e 100644 --- a/etemplate/inc/class.nextmatch_widget.inc.php +++ b/etemplate/inc/class.nextmatch_widget.inc.php @@ -113,7 +113,8 @@ ); switch ($cell['type']) { - case 'nextmatch-sortheader': + case 'nextmatch-sortheader': // Option: default sort: ASC(default) or DESC + $extension_data['default_sort'] = preg_match('/^(ASC|DESC)$/i',$cell['size']) ? strtoupper($cell['size']) : 'ASC'; $cell['type'] = 'button'; $cell['onchange'] = True; if (!$cell['help']) @@ -135,7 +136,7 @@ } return True; - case 'nextmatch-filterheader': + case 'nextmatch-filterheader': // Option: as for selectbox: [extra-label(default ALL)[,#lines(default 1)]] $cell['type'] = 'select'; if (!$cell['size']) { @@ -149,7 +150,7 @@ $extension_data['old_value'] = $value = $nm_global['col_filter'][$this->last_part($name)]; return True; - case 'nextmatch-accountfilter': + case 'nextmatch-accountfilter': // Option: as for selectbox: [extra-label(default ALL)[,#lines(default 1)]] $cell['type'] = 'select-account'; $cell['name'] .= '[account]'; if (!$cell['size']) @@ -305,14 +306,15 @@ if ($value_in) { $nm_global['order'] = $this->last_part($name); + $nm_global['default_sort'] = $extension_data['default_sort']; } return False; // dont report value back, as it's in the wrong location (rows) case 'select-account': // used by nextmatch-accountfilter case 'nextmatch-filterheader': - if ($value_in != $extension_data['old_value']) + if ($value_in != $extension_data['old_value'] && !(!$value_in && !$extension_data['old_value'])) { - //echo "

setting nm_global[filter][".$this->last_part($name)."]=$value_in

\n"; + //echo "

setting nm_global[filter][".$this->last_part($name)."]='$value_in' (was '$extension_data[old_value]')

\n"; $nm_global['filter'][$this->last_part($name)] = $value_in; } return False; // dont report value back, as it's in the wrong location (rows) @@ -381,7 +383,15 @@ elseif ($nm_global['order']) { $value['order'] = $nm_global['order']; - $value['sort'] = $old_value['order'] == $nm_global['order'] && $old_value['sort']!='DESC'?'DESC':'ASC'; + if ($old_value['order'] != $value['order']) + { + $value['sort'] = $nm_global['default_sort']; + } + else + { + $value['sort'] = $old_value['sort'] != 'DESC' ? 'DESC' : 'ASC'; + } + //echo "

old_value=$old_value[order]/$old_value[sort] ==> $value[order]/$value[sort]

\n"; $loop = True; } elseif ($nm_global['filter'])