Dt Simple Sort Columns

Dt Simple Sort Columns

jdadwilsonjdadwilson Posts: 127Questions: 30Answers: 1

I use the following columns structure throughout my site.

columns: [{ data: 'chu_Name', className: 'udatal', orderable: true,  visible: true },
          { data: 'twn_Name', className: 'udatal', orderable: true,  visible: true },
          { data: 'chu_Lat',  className: 'udatar', orderable: false, visible: true },
          { data: 'chu_Lon',  className: 'udatar', orderable: false, visible: true },
          { data: 'chu_Id',   className: 'udatar', orderable: false, visible: false}],

Works great with v1.0. Table columns sort as needed. With v2.0 the table displays and basically functions as desired, BUT the columns will not sort and there are no triangles showing. An inspection shows the following for the first thead tr th cell.

<th data-dt-column="0" class="udatal dt-orderable-none" rowspan="1" colspan="1">
<span class="dt-column-title">Church Name</span><span class="dt-column-order"></span></th>

How do I change the columns definition to work with v2.0.8?

As always, TIA for any assistance
jdadwilson

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    It seems to be working as expected here - the first three columns are orderable, the last three aren't.

    Could you look at that, please, and see if it helps. It would be interesting to understand the differences.

    Colin

  • jdadwilsonjdadwilson Posts: 127Questions: 30Answers: 1

    I suppose you meant 'first TWO columns' not 'first THREE columns'.

    Here are two links to illustrate the difference.

    This page uses v1.0. Table heading includes triangles and sorting works.

    www.msholmes.org/churches

    This page uses v2.0. Table does not include triangles and sorting doesn't work.

    www.txgrayson.org/churches

    Both use the same table initialization parameters.

    So, what do I need to do to make v2.0 sort?

    jdadwilson

  • kthorngrenkthorngren Posts: 21,188Questions: 26Answers: 4,925
    edited July 12

    In datatables-globals.js you have disabled ordering in the default settings:

    $.extend( $.fn.dataTable.defaults, {
    
    ....
        
        ordering: false,
    

    EDIT: Either remove it from the defautls or if you want that as the default then set ordering to true in the specific Datatable.

    Kevin

  • span zspan z Posts: 4Questions: 2Answers: 0
    edited July 12
  • allanallan Posts: 63,262Questions: 1Answers: 10,423 Site admin
    Answer ✓

    https://www.txgrayson.org/java/churches.js
    set ordering: true,

    Not that I can see:

    function init_Table() {
        oTable = $('#mainTable').DataTable({
            ajax: 'assets/ajax/ajax_Churches.php',
    
            columns: [{ data: 'chu_Name', className: 'udatal', orderable: true,  visible: true },
                      { data: 'twn_Name', className: 'udatal', orderable: true,  visible: true },
                      { data: 'chu_Lat',  className: 'udatar', orderable: false, visible: true },
                      { data: 'chu_Lon',  className: 'udatar', orderable: false, visible: true },
                      { data: 'chu_Id',   className: 'udatar', orderable: false, visible: false}],
    
            pageLength: 10
        });
    }
    

    Allan

  • jdadwilsonjdadwilson Posts: 127Questions: 30Answers: 1

    Thanks... setting orderable: true in the defaults made it work.

    jdadwilson

Sign In or Register to comment.