Closed samerda75 closed 3 years ago
You shouldn't do this in the class declaration:
Rec_Count = model.objects.all().count()
if Rec_Count > 500:
length_menu = [[10, 25, 50, 100], [10, 25, 50, 100]]
else:
length_menu = [[10, 25, 50, 100, -1], [10, 25, 50, 100, _("All")]]
since RecCount
would be evaluated only once when the file is imported.
I would rather override get_length_menu
as follows:
def get_length_menu(self):
Rec_Count = model.objects.all().count()
if Rec_Count > 500:
length_menu = [[10, 25, 50, 100], [10, 25, 50, 100]]
else:
length_menu = [[10, 25, 50, 100, -1], [10, 25, 50, 100, _("All")]]
return self.length_menu
Did you encounter other problems?
thank you for your reply it is useful, **But this did not solve my original point, which i would like to show the date range filter fields
can you help in this ?**
Dear @samerda75 , I do my best to share generic advice on the usage of this library, and occasionally add some enhancements on request. However, I regret I have no time to follow specific use cases.
thank you for the valuable library you share, and I do understand your point in the example you include http://django-ajax-datatable-demo.brainstorm.it/tracks/ it has the same idea i am looking for if you can share the source code it will be appreciated
@samerda75 the code can be found here: https://github.com/morlandi/django-ajax-datatable/tree/master/example
I want to make same as below example
i am using the following code [
](url) ajax_datatable_views.py
` class UserLogAjaxDatatableView(AjaxDatatableView): model = Change initial_order = [["date_created", "desc"], ] Rec_Count = model.objects.all().count() if Rec_Count > 500: length_menu = [[10, 25, 50, 100], [10, 25, 50, 100]] else: lengthmenu = [[10, 25, 50, 100, -1], [10, 25, 50, 100, ("All")]] search_values_separator = '+' latest_by = "date_created" show_date_filter = True
`
list-log.html
`
$( document ).ready(function() { function hideSearchInputs(columns) { for (i=0; i<columns.length; i++) { if (columns[i]) { $('.filterhead:eq(' + i + ')' ).show(); } else { $('.filterhead:eq(' + i + ')' ).hide(); } } } AjaxDatatableViewUtils.initialize_table( $('#table_id'), "{% url 'crm:ajax_datatable_logging' %}", { // extra_options (example) processing: false, autoWidth: false, full_row_select: false, scrollX: true, colReorder: true, "pagingType": "full_numbers", responsive: true,
`