Hi,
thanks for your question.
With “static” do you mean that this column shall never change, and always keep the original order?
Unfortunately, I don’t think that this is possible, as the DataTables JavaScript library (which does the sorting), will only move entire rows.
It is possible to deactivate the sorting on that column, but the rows would still change order, depending on the sort in the other columns.
Regards,
Tobias
Yes, with “static” I mean that this column shall never change, and always keep the original order.
Thank you
Hi,
ok, thanks for the clarification.
I just found an example for the DataTables library that does this with some extra code:
http://datatables.net/examples/api/counter_column.html
Is this what you would want?
Best wishes,
Tobias
Hi,
if this is what you want, it seems that you’ll only have to add
"fnDrawCallback": function ( oSettings ) { if ( oSettings.bSorted || oSettings.bFiltered ) { for ( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ ) { $('td:eq(0)', oSettings.aoData[ oSettings.aiDisplay[i] ].nTr ).html( i+1 ); } } }, "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0 ] } ]
to the “Custom Commands” textfield in the “Features of the DataTables JavaScript library” section on the “Edit” screen of your table.
Regards,
Tobias
Hi,
there’s an even better way now 🙂 I created a small “TablePress Extension” (a plugin for the plugin), that now adds this functionality.
Please just install and activate https://github.com/downloads/TobiasBg/TablePress-Extensions/tablepress-datatables-counter-column.zip as a regular WordPress plugin.
After that, you’ll just need to extend your Shortcode from
[table id=123 /]
to
[table id=123 datatables_counter_column=true /]
That extra “Custom Command” that I mentioned above is then no longer necessary, because it’s added automatically.
Regards,
Tobias
Hi,
great to hear that! 🙂 You are welcome!
Best wishes,
Tobias