jquery - Lajittelu poistetaan käytöstä taulukkoissa

original title: "jquery - Disabling sorting in datatables not functioning"


Here is the code i am using

oTable = $('#example').dataTable({
                "bSort": false,
                "aoColumns": [ 
                   { "bSortable": false },
                   { "bSortable": false },
                   { "bSortable": false } ] 

The problem i'm having is that the table starts off blank and its populated by user input. Once the user starts to input things into the table, it sorts them by product ID. I'm trying to remove this sorting so that it just lists them as they are input.

EDIT: I have come to the conclusion that NONE of my initialization settings are working. I believe it has to do with the fnAddRow when the table is empty except for headers.

EDIT2: I've isolated it down to the fnAddData. When I initialize the table with trash data everything is formatted as its supposed to be but then once i use the fnAddData, it removes all formating

Tässä on koodi, jota käytän oTable = $ ('# esimerkki'). DataTable ({"bSort": false, "bStateSave": true, "aoColumns": [...

Tämä on yhteenveto käännöksen jälkeen. Jos haluat tarkastella koko käännöstä, napsauta käännä-kuvaketta

Kaikki vastaukset
  • Translate

    Try this:

    $(document).ready( function () {$('#example').dataTable( {
        "bSort": false
      } );

  • Translate

    try this:

    this is to disable initial sort

    $(document).ready( function() {
        "aaSorting": []

  • Translate

    Since version 1.10 of DataTables, you can use the following option to disable the ordering completely:

      ordering: false

    Also see: https://datatables.net/reference/option/ordering

  • Translate

    bSort ( http://datatables.net/ref#bSort ) is the correct way to disable sorting in DataTables. Perhaps you can link to your example which shows sorting still enabled with this parameter set please?

  • Translate

    use the below code

    "aoColumnDefs": [
      { "bSortable": false, "aTargets": [ 0 ] }
    ] } );

    OR use the link http://datatables.net/ref#bSortable

  • Translate

    try this one,

    set data-orderable ="false" in the table header tag

    <table id="orders">
           <th data-orderable="false">ID</th>
           <th>Customer Name</th>
           <th data-orderable="false">Total</th>
           <th data-orderable="false">Action</th>

  • Translate

    Default sorting can be set by asSorting parameter. Please see: