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

dont show column filters #101

Open alexeydg opened 1 year ago

alexeydg commented 1 year ago

Hello, in your demo has flters image in my example they don't show image

model = Product
    title = 'каталог'
    initial_order = [["name", "asc"], ]
    length_menu = [[10, 20, 50, 100, -1], [10, 20, 50, 100, 'all']]
    search_values_separator = '+'

    column_defs = [
        {'name': 'sku', 'visible': True, 'title': 'Артикул'},
        {'name': 'name', 'visible': True, 'placeholder': True, 'title': 'Название товара'},
        {'name': 'brand', 'foreign_field': 'brand__name', 'visible': True,},
        {'name': 'brand_id', 'visible': True,},
        {'name': 'buttons', 'visible': True, 'placeholder': True, 'searchable': False, 'width': '300',
            'orderable': False, 'title': ''}
    ]
....
<script language="javascript">
        $(document).ready(function() {
            AjaxDatatableViewUtils.initialize_table(
                $('#datatable_product'),
                "{% url 'ecom:ajax_datatable_ecom_product' %}",
                {
                    // extra_options (example)
                    processing: false,
                    autoWidth: false,
                    full_row_select: false,
                    scrollX: false,
                    language: {
                       url: "/static/plugins/datatables/ru.json"
                    },
                }, {
                    // extra_data
                },
            );
        });

    </script>
alexeydg commented 1 year ago

I found a bug, if you connect the translation from the json file, then the filter is not shown

language: {
                       url: "/static/plugins/datatables/ru.json"
                    },
hbast commented 1 year ago

I can confirm the behavior described above. The filter are gone after activating the translation via the json file. I used the german translation file.

morlandi commented 1 year ago

Oh, thank you ... that's really puzzling, isn't it?

I will label this issue as a bug and sooner or later hopefully investigate it.

In the meantime, a quick and dirty workaround, although not very elegant, could be:

language: {
    "sProcessing":   "Подождите...",
    "sLengthMenu":   "Показать _MENU_ записей",
    "sZeroRecords":  "Записи отсутствуют.",
    "sInfo":         "Записи с _START_ до _END_ из _TOTAL_ записей",
    "sInfoEmpty":    "Записи с 0 до 0 из 0 записей",
    "sInfoFiltered": "(отфильтровано из _MAX_ записей)",
    "sInfoPostFix":  "",
    "sSearch":       "Поиск:",
    "sUrl":          "",
    "oPaginate": {
        "sFirst": "Первая",
        "sPrevious": "Предыдущая",
        "sNext": "Следующая",
        "sLast": "Последняя"
    },
    "oAria": {
        "sSortAscending":  ": активировать для сортировки столбца по возрастанию",
        "sSortDescending": ": активировать для сортировки столбцов по убыванию"
    }
}

instead of

language: {
    url: "https://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Russian.json"
}
hbast commented 1 year ago

see also https://github.com/morlandi/django-ajax-datatable/issues/87