Column set to Orderable False shows sorting icon until a column that is orderable is clicked on

Column set to Orderable False shows sorting icon until a column that is orderable is clicked on

paul@dmcreative.compaul@dmcreative.com Posts: 27Questions: 5Answers: 0

Environment: DataTables version 1.10.10 and Editor 1.5.4, Server side processing using the Editor PHP libraries

I am trying to create a table with a custom order by statement that is set from within the script but does not allow the user to select or change the ordering.

Following is what I have been able to achieve, but it is not perfect.

If the following function is used it generates an Invalid JSON response.

ordering: false

The first part of the JSON response include the following data:

<br />
<b>Notice</b>: Undefined index: order in <b>../Editor.php</b> on line <b>1171</b><br />

I determined that the request string did NOT include the following sections
order[0][column]=0
order[0][dir]=asc

If the following line is added to the javascript, the request string still does not include the order sections and generates an Invalid JSON response..

order:[[1,'asc'],[0,'asc']]

Instead of using the ordering:false setting I used the columns attribute to turn off ordering and kept the order statement, this produced the desired results except that the class for the header is set to sorting_asc when it should be set to sorting_disabled, and as such displays a sorting triangle to the right of the column title.

columns: [
{ data: "CPRT_STREET_NO",
orderable: false },
{ data: "CPRT_STREET",
orderable: false }
],

order:[[1,'asc'],[0,'asc']]

So my question is how do I correct the class of the header?

Note: If the first column is set to orderable:false and the second column is set to orderable:true the header when first created will set the class of the first column to sorting_asc and after the second header is selected the first header will have it's class changed to sorting_disabled with the subsequent removal of the up or ascending triangle next to the column header title.

This question has an accepted answers - jump to answer

Answers

  • jr42.gordonjr42.gordon Posts: 305Questions: 2Answers: 49

    I have found that adding the below code to the "columnDef" to make a column not sortable,

    "sorting": false,
    "orderable": false,
    

    Also, take a look at https://datatables.net/reference/option/orderFixed

  • allanallan Posts: 61,880Questions: 1Answers: 10,139 Site admin
    Answer ✓

    Hi,

    Yes, I think that the orderFixed is probably the best option here if you want to define the order. The server-side libraries always expect the order to come from the client-side, but you can disallow the user's ability to specify ordering and use your own with that option.

    Allan

This discussion has been closed.