Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Datatables Natural Sort

BWBama85 free asked 5 years ago


I am currently using this code:

<script>jQuery(document).ready(function () {
        jQuery('#dtSort').DataTable({
            columnDefs: [
                { type: 'natural-nohtml', targets: 3 }
            ],
            "iDisplayLength": 25
            });
        jQuery('.dataTables_length').addClass('bs-select');
        });</script>

To sort Naturally on this page: https://www.bamapolitics.com/alabama/alabama-government-officials/alabama-state-senators/

I'd like for:

  1. The arrows in the starts in the first colum (0) instead of the fourth column (3).
  2. I'd like to disable to first column.

Jakub Strebeyko staff commented 5 years ago

Hi there, @BWBama85 Thanks for reaching out! 1. I want to clarify which arrows do you exactly mean? 2. I am afraid there is no way to disable chosen columns as of time being.

Best, Kuba


Ozcan Arslan pro answered 5 years ago


Add this part and you can enable/disable column behaivours and to say which column is sorted as default

        "aaSorting": [[3, "desc"]],
           "aoColumns": [
            /* column1  */ {"bSearchable": false, "bSortable": false},
            /* column2 */ {"bSearchable": true, "bSortable": true},
            /* column3 */ {"bSearchable": true, "bSortable": false},
            /* column4 */ {"bSearchable": false, "bSortable": true},
            /* column5 */ {"bSearchable": true, "bSortable": true}
            .
            .
            .
        ]

Jakub Mandra staff commented 5 years ago

Great one! Thanks for posting :)



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.7.3
  • Device: Desktop
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: Yes