django-ajax-datatable
django-ajax-datatable copied to clipboard
dont show column filters
Hello, in your demo has flters
in my example they don't show
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>
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"
},
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.
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"
}
see also https://github.com/morlandi/django-ajax-datatable/issues/87