You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-9
Original file line number
Diff line number
Diff line change
@@ -23,17 +23,18 @@ _django_datatables_view_ uses **GenericViews**, so your view should just inherit
23
23
(there is also a DatatableMixin - pure datatables handler that can be used with the mixins of your choice, eg. django-braces). These are:
24
24
25
25
***model** - the model that should be used to populate the datatable
26
-
***columns** - the columns that are going to be displayed
27
-
***order_columns** - list of column names used for sorting (eg. if user sorts by second column then second column name from this list will be used with order by clause).
28
-
***filter_queryset** - if you want to filter your datatable then override this method
26
+
***columns** - the columns that are going to be displayed. If not defined then django_datatables_view will look for 'name' in the columns definition provided in the request by DataTables, eg.: columnDefs: [{name: 'name', targets: [0]} (only works for datatables 1.10+)
27
+
***order_columns** - list of column names used for sorting (eg. if user sorts by second column then second column name from this list will be used with order by clause). If not defined then django_datatables_view will look for 'name' in the columns definition provided in the request by DataTables, eg.: columnDefs: [{name: 'name', targets: [0]} (only works for datatables 1.10+)
28
+
***filter_queryset** - if you want to filter your DataTable in some specific way then override this method. In case of older DataTables (pre 1.10) you need to override this method or there will be no filtering.
29
+
***filter_method** - returns 'istartswith' by default, you can override it to use different filtering method, e.g. icontains: return self.FILTER_ICONTAINS
29
30
30
31
For more advanced customisation you might want to override:
31
32
32
33
***get_initial_queryset** - method that should return queryset used to populate datatable
33
34
***prepare_results** - this method should return list of lists (rows with columns) as needed by datatables
34
35
***escape_values** - you can set this attribute to False in order to not escape values returned from render_column method
35
36
36
-
The code is rather simple so do not hesitate to have a look at it. Method that is executed first (and that calls other methods) is **get_context_data**
37
+
The code is rather simple so do not hesitate to have a look at it. Method that is executed first (and that calls other methods to execute whole logic) is **get_context_data**. Definitely have a look at this method!
37
38
38
39
See example below:
39
40
@@ -71,12 +72,12 @@ See example below:
71
72
# use parameters passed in GET request to filter queryset
0 commit comments