Patch for forced secondary etc. sorts

Patch for forced secondary etc. sorts

syndesissyndesis Posts: 12Questions: 0Answers: 0
edited December 2013 in DataTables 1.9
I had a requirement similar to the one in http://www.datatables.net/forums/discussion/comment/45129

You mentioned that maybe DataTables should provide an option for this internally so I added one. This option is nearly identical to aaSortingFixed, except it sorts after the selected sort instead of before. Patch follows. Please let me know if I should submit a pull request or if you think it should be implemented in a different way.

[code]
diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js
index 89179c8..ea39b9e 100644
--- a/media/js/jquery.dataTables.js
+++ b/media/js/jquery.dataTables.js
@@ -2057,7 +2057,11 @@
aaSort = ( oSettings.aaSortingFixed !== null ) ?
oSettings.aaSortingFixed.concat( oSettings.aaSorting ) :
oSettings.aaSorting.slice();
-
+
+ if ( oSettings.aaPostSort !== null ) {
+ aaSort = aaSort.concat( oSettings.aaPostSort );
+ }
+
for ( i=0 ; i

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    I like it - thanks for this! The code had changed a bit in the 1_10_wip branch for how the sorting is applied, so it wouldn't apply directly to the current code, but the principle of the change looks just about ideal.

    In 1.10 the aaSortingFixed parameter is now primarily referred to as `orderingFixed` (backwards compatible!), so I'm wondering if it should be an object which allows post fix and prefix parameters when given as an object...

    Allan
  • syndesissyndesis Posts: 12Questions: 0Answers: 0
    I was thinking something along those lines as well - one object with a parameter for pre/post. I'll take a look at the 1_10_wip branch.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    I've just put this into 1.10 now: https://github.com/DataTables/DataTablesSrc/commit/953038e :-). One step closer to beta!

    Regards,
    Allan
  • syndesissyndesis Posts: 12Questions: 0Answers: 0
    Great, thanks!
This discussion has been closed.