morlandi / django-ajax-datatable

A Django app which provides the integration of a Django project with the jQuery Javascript library DataTables.net
MIT License
215 stars 65 forks source link

Loding language file from url discards column definition #87

Open hbast opened 2 years ago

hbast commented 2 years ago

Hello all, I would like to load a language file as json during initialization instead of entering all translations manually. For this I wrote the following code

    <script type="text/javascript">
        $(document).ready(function() {
            AjaxDatatableViewUtils.initialize_table(
                $('#datatable_{{ event.slug }}'),
                "{% url 'issue_datatable' %}",
                {
                    processing: false,
                    autoWidth: true,
                    full_row_select: false,
                    scrollX: false,
                    language: {
                       url: "{% static 'datatables/de-DE.json' %}"
                    },
                }, {
                    slug: '{{ event.slug }}',
                }
            );
        });
    </script>

If I include the language package like this, all configurations I made in Python, e.g. autofilter or orderable settings are discarded. The table is rendered without autofilter and orderable. However, the language pack is loaded correctly.

If I enter the translations manually, as it says in the instructions, everything works fine.

I also tried putting the language + url inside AjaxDatatableViewUtils.init() but this didn't worked too.

Edit: this is the link to the language file: https://cdn.datatables.net/plug-ins/1.12.0/i18n/de-DE.json