Configuration in .ready(function) not used

Issue #36 invalid
Mark Spehalski created an issue

I just started using django-datatables-view and it seems the content of the .js script is not used. In fact I created and empty function:

$(document).ready(function() {
    var dt_table = $('.datatable').dataTable({
    });
});

// Using the first or second function always generates same table.

$(document).ready(function() {
    var dt_table = $('.datatable').dataTable({
        order: [[ 0, "desc" ]],
        lengthMenu: [[10, 25, 50, 100, -1], [10, 25, 50, 100, "ALL"]],
        columnDefs: [
            {orderable: true,
             searchable: true,
            }
        ],
        searching: true,
        processing: true,
        serverSide: true,
        stateSave: true,
        ajax: USERS_LIST_JSON_URL, // Assigned in HTML
        language: dt_variables     // Assigned in HTML
    });
});

I call it from my HTML. Changing the contents has no effect on the generated table. It seems to always be using defaults.

{% block extra_head %}
    <link rel="stylesheet" type="text/css" href='{% static "css/datatables.min.css" %}'/>
    <script type="text/javascript" charset="utf8" src='{% static "js/datatables.min.js" %}'></script>

    <script src="{% static "js/results_datatable_config.js" %}"></script>

    <script type="text/javascript">
        var USERS_LIST_JSON_URL = '{% url "results_dt" %}';
        // translations for datatables

        var dt_language = {
        }

    </script>
{% endblock %}

Also, the contents of the dt_language variable doesn't matter either. Am I missing something here. How do change tables appearance, i.e. menu list, column attributes, etc. It seems like only using internal defaults. Thanks

Comments (1)

  1. Maciej Wisniowski repo owner

    django-datatables-view is a server side module and it has nothing to do with frontend part. Anyway, in this case, it might be that you're using an old version of DataTables script with new parameters in configuration.

  2. Log in to comment