Disable sorting on first column

Disable sorting on first column

geckoroutesgeckoroutes Posts: 2Questions: 1Answers: 0

Hi there!

I am using the Tablepress Wordpress plugin and would like to include an extra option. I want to disable sorting in the first column and keep the sorting active on the other columns.

I inserted the following code in the "custom Commands" in the editing mode of the table with id 'top10'.

$('#top10').dataTable( {
"columnDefs": [
{ "orderable": false, "targets": 0 }
]
} );

When saving this, I loose all the sorting options of all column however.

Any suggestion to get this working?

Sorry for the beginner question, but I really can't get it working after reading and trying out different options for 2 hours,

Answers

  • colincolin Posts: 15,236Questions: 1Answers: 2,598

    Hi @geckoroutes ,

    That's the correct syntax, see here. If it's a WordPress plugin, it might be worth contacting the author.

    Cheers,

    Colin

  • geckoroutesgeckoroutes Posts: 2Questions: 1Answers: 0

    Thanks for the comment. I already solved it by leaving out the first row with the table name.

    This code worked for me:

    "columnDefs": [
    { "orderable": false, "targets": 0 }
    ]

This discussion has been closed.