Dejell Dejell - 3 months ago 19x
Python Question

django-datatable default iDisplayLength

I am using for a table.

By default, it would display only 10 records, and there is a Length Menu to choose a different number.

I see in the Ajax call that it asks for

on first load.

How can I overwrite it to display 100 at first?

I read through the source code and the documentation, but I am newbie to django and not sure how to overwrite it


I can see from their source code: class TableOptions which is used for meta options and can be accessed for the same to set different properties.

So as I see it, adding a Meta can help you, like this:

class AjaxTable(Table):
    id = Column(field='id', header=u'#')
    name = Column(field='name', header=u'NAME')
    organization = Column(field='', header=u'ORG')

    class Meta:
        model = Person
        ajax = True
        page_length = 100  # Add this and see

The page_length is the set of options that I could see inside the TableOptions