1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-04-11 03:02:30 +02:00

Fix: Feature match the server-side sorting to the client-side sorting for what information is sent to the server for sorting. Previously aDataSort was no honored - https://twitter.com/#!/naomiaro/status/172397914239414272

This commit is contained in:
Allan Jardine 2012-02-22 19:47:09 +00:00
parent bc756f3a69
commit 872dc0db3e
3 changed files with 40 additions and 42 deletions

View File

@ -1788,8 +1788,8 @@
function _fnAjaxParameters( oSettings ) function _fnAjaxParameters( oSettings )
{ {
var iColumns = oSettings.aoColumns.length; var iColumns = oSettings.aoColumns.length;
var aoData = [], mDataProp; var aoData = [], mDataProp, aaSort, aDataSort;
var i; var i, j;
aoData.push( { "name": "sEcho", "value": oSettings.iDraw } ); aoData.push( { "name": "sEcho", "value": oSettings.iDraw } );
aoData.push( { "name": "iColumns", "value": iColumns } ); aoData.push( { "name": "iColumns", "value": iColumns } );
@ -1820,20 +1820,24 @@
/* Sorting */ /* Sorting */
if ( oSettings.oFeatures.bSort !== false ) if ( oSettings.oFeatures.bSort !== false )
{ {
var iFixed = oSettings.aaSortingFixed !== null ? oSettings.aaSortingFixed.length : 0; var iCounter = 0;
var iUser = oSettings.aaSorting.length;
aoData.push( { "name": "iSortingCols", "value": iFixed+iUser } ); aaSort = ( oSettings.aaSortingFixed !== null ) ?
for ( i=0 ; i<iFixed ; i++ ) oSettings.aaSortingFixed.concat( oSettings.aaSorting ) :
{ oSettings.aaSorting.slice();
aoData.push( { "name": "iSortCol_"+i, "value": oSettings.aaSortingFixed[i][0] } );
aoData.push( { "name": "sSortDir_"+i, "value": oSettings.aaSortingFixed[i][1] } );
}
for ( i=0 ; i<iUser ; i++ ) for ( i=0 ; i<aaSort.length ; i++ )
{ {
aoData.push( { "name": "iSortCol_"+(i+iFixed), "value": oSettings.aaSorting[i][0] } ); aDataSort = oSettings.aoColumns[ aaSort[i][0] ].aDataSort;
aoData.push( { "name": "sSortDir_"+(i+iFixed), "value": oSettings.aaSorting[i][1] } );
for ( j=0 ; j<aDataSort.length ; j++ )
{
aoData.push( { "name": "iSortCol_"+iCounter, "value": aDataSort[j] } );
aoData.push( { "name": "sSortDir_"+iCounter, "value": aaSort[i][1] } );
iCounter++;
}
} }
aoData.push( { "name": "iSortingCols", "value": iCounter } );
for ( i=0 ; i<iColumns ; i++ ) for ( i=0 ; i<iColumns ; i++ )
{ {
@ -3778,14 +3782,9 @@
if ( !oSettings.oFeatures.bServerSide && if ( !oSettings.oFeatures.bServerSide &&
(oSettings.aaSorting.length !== 0 || oSettings.aaSortingFixed !== null) ) (oSettings.aaSorting.length !== 0 || oSettings.aaSortingFixed !== null) )
{ {
if ( oSettings.aaSortingFixed !== null ) aaSort = ( oSettings.aaSortingFixed !== null ) ?
{ oSettings.aaSortingFixed.concat( oSettings.aaSorting ) :
aaSort = oSettings.aaSortingFixed.concat( oSettings.aaSorting ); oSettings.aaSorting.slice();
}
else
{
aaSort = oSettings.aaSorting.slice();
}
/* If there is a sorting data type, and a fuction belonging to it, then we need to /* If there is a sorting data type, and a fuction belonging to it, then we need to
* get the data from the developer's function and apply it for this column * get the data from the developer's function and apply it for this column

View File

@ -38,8 +38,8 @@ function _fnAjaxUpdate( oSettings )
function _fnAjaxParameters( oSettings ) function _fnAjaxParameters( oSettings )
{ {
var iColumns = oSettings.aoColumns.length; var iColumns = oSettings.aoColumns.length;
var aoData = [], mDataProp; var aoData = [], mDataProp, aaSort, aDataSort;
var i; var i, j;
aoData.push( { "name": "sEcho", "value": oSettings.iDraw } ); aoData.push( { "name": "sEcho", "value": oSettings.iDraw } );
aoData.push( { "name": "iColumns", "value": iColumns } ); aoData.push( { "name": "iColumns", "value": iColumns } );
@ -70,20 +70,24 @@ function _fnAjaxParameters( oSettings )
/* Sorting */ /* Sorting */
if ( oSettings.oFeatures.bSort !== false ) if ( oSettings.oFeatures.bSort !== false )
{ {
var iFixed = oSettings.aaSortingFixed !== null ? oSettings.aaSortingFixed.length : 0; var iCounter = 0;
var iUser = oSettings.aaSorting.length;
aoData.push( { "name": "iSortingCols", "value": iFixed+iUser } ); aaSort = ( oSettings.aaSortingFixed !== null ) ?
for ( i=0 ; i<iFixed ; i++ ) oSettings.aaSortingFixed.concat( oSettings.aaSorting ) :
{ oSettings.aaSorting.slice();
aoData.push( { "name": "iSortCol_"+i, "value": oSettings.aaSortingFixed[i][0] } );
aoData.push( { "name": "sSortDir_"+i, "value": oSettings.aaSortingFixed[i][1] } );
}
for ( i=0 ; i<iUser ; i++ ) for ( i=0 ; i<aaSort.length ; i++ )
{ {
aoData.push( { "name": "iSortCol_"+(i+iFixed), "value": oSettings.aaSorting[i][0] } ); aDataSort = oSettings.aoColumns[ aaSort[i][0] ].aDataSort;
aoData.push( { "name": "sSortDir_"+(i+iFixed), "value": oSettings.aaSorting[i][1] } );
for ( j=0 ; j<aDataSort.length ; j++ )
{
aoData.push( { "name": "iSortCol_"+iCounter, "value": aDataSort[j] } );
aoData.push( { "name": "sSortDir_"+iCounter, "value": aaSort[i][1] } );
iCounter++;
}
} }
aoData.push( { "name": "iSortingCols", "value": iCounter } );
for ( i=0 ; i<iColumns ; i++ ) for ( i=0 ; i<iColumns ; i++ )
{ {

View File

@ -22,14 +22,9 @@ function _fnSort ( oSettings, bApplyClasses )
if ( !oSettings.oFeatures.bServerSide && if ( !oSettings.oFeatures.bServerSide &&
(oSettings.aaSorting.length !== 0 || oSettings.aaSortingFixed !== null) ) (oSettings.aaSorting.length !== 0 || oSettings.aaSortingFixed !== null) )
{ {
if ( oSettings.aaSortingFixed !== null ) aaSort = ( oSettings.aaSortingFixed !== null ) ?
{ oSettings.aaSortingFixed.concat( oSettings.aaSorting ) :
aaSort = oSettings.aaSortingFixed.concat( oSettings.aaSorting ); oSettings.aaSorting.slice();
}
else
{
aaSort = oSettings.aaSorting.slice();
}
/* If there is a sorting data type, and a fuction belonging to it, then we need to /* If there is a sorting data type, and a fuction belonging to it, then we need to
* get the data from the developer's function and apply it for this column * get the data from the developer's function and apply it for this column