angular-datatables icon indicating copy to clipboard operation
angular-datatables copied to clipboard

withOption columnDefs orderable not working

Open alenb opened this issue 10 years ago • 4 comments

Hi all,

Using orderable within the ColumnDefs via withOption doesn't actually show the ordering buttons.

Here's my version of the table with just one column to show what I mean:

$scope.invoicesTable.dtOptions = DTOptionsBuilder.newOptions()
.withOption('columnDefs', [
    {
        targets: 0, data: 'identify', searchable: false, orderable: true, render: function( data, type, row ) {
            return '<span class="label label-default">'+ data +'</span>';
        }
    }
])
.withOption('order', [[ 0, 'asc' ]]);

Thank you!

alenb avatar Dec 13 '15 22:12 alenb

The ordering buttons are images from DT vendor folder. You need to include the DT CSS and your images should be in a public folder.

image

l-lin avatar Dec 15 '15 14:12 l-lin

The buttons themselves aren't showing i.e. ordering is not working.

It works fine if I were to use DTColumnBuilder, but using this method seems to wipe anything else set in the <thead> when the table is redrawn.

edit: I believe I've managed to narrow it down for you. The one thing that I omitted above is the thing that's causing the order buttons to disappear, which is the server side code.

.withOption('ajax', {
    url: invoices_object.ajax_url,
    type: 'POST',
    data: function( data, dtInstance ) {}
})
.withDataProp('data')
.withOption('serverSide', true)

Commenting out the server-side code displays the ordering buttons without any issues.

Hope that's enough info here, please let me know if you require anything else.

alenb avatar Dec 17 '15 03:12 alenb

Any ideas as to why this may be happening?

alenb avatar Jan 18 '16 22:01 alenb

Sorry for the late answer.

If you are using the DTColumnBuilder, then you do not need to specify the <thead> in your HTML as DataTables will include it by itself.

However, I cannot reproduce your issue, with server side or not, as the buttons are displayed. Logically, be it server side or not, the buttons do not depend on this parameter to be displayed.

Can you try to reproduce the issue on a plnkr or something alike?

l-lin avatar Jan 22 '16 08:01 l-lin