Sorting - column not sortable

Issue #34 invalid
Former user created an issue

Hello,

My BaseDatatableView creates rows with 4 columns. Thef first one and the last one, are non-sortable HTML stuff, and the two middle columns are model attributes. It's defined like:

order_columns = ['', 'attributeA', 'attributeB', '']

When the table is loaded for the first time, it throws and alert. The error is as follows:

  File "/webapps/holz_logistiksystem/lib/python3.5/site-packages/django/db/models/sql/query.py", line 1665, in add_ordering
    raise FieldError('Invalid order_by arguments: %s' % errors)
django.core.exceptions.FieldError: Invalid order_by arguments: ['']

Nothing is shown in the table. It seems the table tried to order by the first argument, because the arrow next to the title looks selected. However, If I click on the sortable attributes, it loads everything ok.

It seems like a bug. Or am I using it wrong?

Comments (3)

  1. Maciej Wisniowski repo owner

    Columns defined in 'order_columns' have to match DataTables columns definition in JS. If you see such error then somehow DataTables is passing invalid column number to sort by. Please verify what is sent in request as: order[0][column].

    Might be that you've already ordered your DataTable by invalid column and now it is stored by DataTables, eg. in cookie (you might want to try Incognito mode) so that initial column doesn't apply.

  2. Log in to comment