From 2bb96f89b0f19ec5b58f2189d13532b94c8ab4bb Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Sat, 30 Oct 2010 06:54:10 +0100 Subject: [PATCH] Fixed: When state saving, it was possible to have a situation where by a table would contain 'n' columns, the user would sort on the last column and then the html is modifed to only have 'n-1' columns. This resulted in a JS error when DataTables tried to restore sorting on the removed column. Now do a sanity check to ensure the sorting column is present, and if not add sorting on column 0. --- media/js/jquery.dataTables.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 9be54261..112134cf 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -6727,6 +6727,10 @@ */ for ( i=0, iLen=oSettings.aaSorting.length ; i= oSettings.aoColumns.length ) + { + oSettings.aaSorting[i][0] = 0; + } var oColumn = oSettings.aoColumns[ oSettings.aaSorting[i][0] ]; /* Add a default sorting index */