Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions table/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def get_columns(cls, token):
class TableWidgets(object):
def __init__(self, table):
opts = table.opts
self.search_box = SearchBox(opts.search, opts.search_placeholder)
self.length_menu = LengthMenu(opts.length_menu)
self.info_label = InfoLabel(opts.info, opts.info_format)
self.search_box = SearchBox(opts.search, opts.search_placeholder, opts.search_label)
self.length_menu = LengthMenu(opts.length_menu, opts.length_menu_format)
self.info_label = InfoLabel(opts.info, opts.info_format, opts.info_filtered, opts.info_post_fix)
self.pagination = Pagination(opts.pagination,
opts.page_length,
opts.pagination_first,
Expand Down Expand Up @@ -173,9 +173,12 @@ def __init__(self, options=None):
# options for table add-on
self.search = getattr(options, 'search', True)
self.search_placeholder = getattr(options, 'search_placeholder', None)
self.search_label = getattr(options, 'search_label', None)

self.info = getattr(options, 'info', True)
self.info_format = getattr(options, 'info_format', None)
self.info_filtered = getattr(options, 'info_filtered', None)
self.info_post_fix = getattr(options, 'info_post_fix', None)

self.pagination = getattr(options, 'pagination', True)
self.page_length = getattr(options, 'page_length', 10)
Expand All @@ -185,6 +188,7 @@ def __init__(self, options=None):
self.pagination_next = getattr(options, 'pagination_next', None)

self.length_menu = getattr(options, 'length_menu', True)
self.length_menu_format = getattr(options, 'length_menu_format', None)

self.ext_button = getattr(options, 'ext_button', False)
self.ext_button_template = getattr(options, 'ext_button_template', None)
Expand All @@ -195,6 +199,14 @@ def __init__(self, options=None):
self.theme_css_file = getattr(options, 'theme_css_file', 'table/css/datatable.bootstrap.css')
self.theme_js_file = getattr(options, 'theme_js_file', 'table/js/bootstrap.dataTables.js')

self.decimal_format = getattr(options, 'decimal_format', u'')
self.thousands_format = getattr(options, 'thousands_format', u',')
self.empty_table = getattr(options, 'empty_table', u'No data available in table')
self.loading_records = getattr(options, 'loading_records', u'Loading...')
self.processing = getattr(options, 'processing', u'Processing...')
self.aria_sort_ascending = getattr(options, '', u': activate to sort column ascending')
self.aria_sort_decending = getattr(options, '', u': activate to sort column decending')


class TableMetaClass(type):
""" Meta class for create Table class instance.
Expand Down
13 changes: 13 additions & 0 deletions table/templates/table/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,27 @@
{% endfor %}
],
"language": {
"decimal": "{{ table.opts.decimal_format }}",
"emptyTable": "{{ table.opts.empty_table }}",
"info": "{{ table.addons.info_label.format }}",
"infoEmpty": "{{ table.addons.info_label.format }}",
"infoFiltered": "{{ table.addons.info_label.filtered }}",
"infoPostFix": "{{ table.addons.info_label.post_fix }}",
"thousands": "{{ table.opts.thousands_format }}",
"lengthMenu": "{{ table.addons.length_menu.format }}",
"loadingRecords": "{{ table.opts.loading_records }}",
"processing": "{{ table.opts.processing }}",
"search": "{{ table.addons.search.label }}",
"zeroRecords": "{{ table.opts.zero_records }}",
"paginate": {
"first": "{{ table.addons.pagination.first }}",
"last": "{{ table.addons.pagination.last }}",
"next": "{{ table.addons.pagination.next }}",
"previous": "{{ table.addons.pagination.prev }}"
},
"aria": {
"sortAscending": "{{ table.opts.aria_sort_ascending }}",
"sortDescending": "{{ table.opts.aria_sort_decending }}"
}
},
"initComplete": function(oSettings, json) {
Expand Down
10 changes: 7 additions & 3 deletions table/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@


class SearchBox(object):
def __init__(self, visible=True, placeholder=None):
def __init__(self, visible=True, placeholder=None, label=None):
self.visible = visible
self.placeholder = placeholder or "Search"
self.label = label or "Search:"

@property
def dom(self):
Expand All @@ -19,9 +20,11 @@ def dom(self):


class InfoLabel(object):
def __init__(self, visible=True, format=None):
def __init__(self, visible=True, format=None, filtered=None, post_fix=None):
self.visible = visible
self.format = format or "Total _TOTAL_"
self.filtered = filtered or '(filtered from _MAX_ total entries)'
self.post_fix = post_fix or ""

@property
def dom(self):
Expand Down Expand Up @@ -52,8 +55,9 @@ def dom(self):


class LengthMenu(object):
def __init__(self, visible=True):
def __init__(self, visible=True, format=None):
self.visible = visible
self.format = format or "Show _MENU_ entries"

@property
def dom(self):
Expand Down