- Correct intial sort order of a table if the default sort column is not an "alphabetical" column (i.e. IP Address)
- Properly sort on the first column (name) when the name is made of a column with a different sort algorithm (i.e. IP Address).

SVN:trunk[2459]
This commit is contained in:
Denis Flaven
2012-11-23 15:25:55 +00:00
parent 9bc263b106
commit ea48279a90
3 changed files with 15 additions and 5 deletions

View File

@@ -506,16 +506,17 @@ EOF;
$aDefaultSort[] = "[".($iColOffset).",".($bAscending ? '0' : '1')."]";
}
}
$sSortList = '';
$sFakeSortList = '';
if (count($aDefaultSort) > 0)
{
$sSortList = ', sortList: ['.implode(',', $aDefaultSort).']';
$sFakeSortList = '['.implode(',', $aDefaultSort).']';
}
$sOQL = addslashes($this->oSet->GetFilter()->serialize());
$oPage->add_ready_script(
<<<EOF
var oTable = $('#{$this->iListId} table.listResults');
oTable.tablesorter( { $sHeaders widgets: ['myZebra', 'truncatedList'] $sSortList} ).tablesorterPager({container: $('#pager{$this->iListId}'), totalRows:$iCount, size: $iPageSize, filter: '$sOQL', extra_params: '$sExtraParams', select_mode: '$sSelectModeJS', displayKey: $sDisplayKey, columns: $sJSColumns, class_aliases: $sJSClassAliases $sCssCount});
oTable.tablesorter( { $sHeaders widgets: ['myZebra', 'truncatedList']} ).tablesorterPager({container: $('#pager{$this->iListId}'), totalRows:$iCount, size: $iPageSize, filter: '$sOQL', extra_params: '$sExtraParams', select_mode: '$sSelectModeJS', displayKey: $sDisplayKey, columns: $sJSColumns, class_aliases: $sJSClassAliases $sCssCount});
oTable.trigger("fakesorton", [$sFakeSortList]);
EOF
);
//if ($iNbPages == 1)

View File

@@ -42,7 +42,7 @@ class NiceWebPage extends WebPage
$this->add_linked_script('../js/jquery-ui-1.8.17.custom.min.js');
$this->add_linked_script("../js/hovertip.js");
// table sorting
$this->add_linked_script("../js/jquery.tablesorter.min.js");
$this->add_linked_script("../js/jquery.tablesorter.js");
$this->add_linked_script("../js/jquery.tablesorter.pager.js");
$this->add_linked_script("../js/jquery.tablehover.js");
$this->add_linked_script('../js/field_sorter.js');

View File

@@ -105,7 +105,16 @@ try
{
if ($iSortCol == $iSortIndex)
{
$aOrderBy['friendlyname'] = (utils::ReadParam('sort_order', 'asc') == 'asc');
$aNameSpec = MetaModel::GetNameSpec($oFilter->GetClass());
if ($aNameSpec[0] == '%1$s')
{
// The name is made of a single column, let's sort according to the sort algorithm for this column
$aOrderBy[$aNameSpec[1][0]] = (utils::ReadParam('sort_order', 'asc') == 'asc');
}
else
{
$aOrderBy['friendlyname'] = (utils::ReadParam('sort_order', 'asc') == 'asc');
}
}
}
else