def setup_table(table): table.add_columns( ('id', { 'column_defs': { 'width': '30px' } }), 'name', ColumnBase( column_name='title', field='person__title', choices=dict(models.Person._meta.get_field('title').choices), render=[render_replace(html='ABC -%1%- DFG', column='title')]), ColumnBase(column_name='Title', field=['person__title', 'person__first_name'], render=[{ 'function': 'Replace', 'html': '<span class="badge badge-success"> %1% </span>', 'column': 'Title:0', 'null_value': '<span class="badge badge-primary"> %2% </span>', 'var': '%1%' }, { 'function': 'Replace', 'column': 'Title:1', 'var': '%2%' }]), ) table.table_options['row_href'] = [ render_replace(column='id', html='javascript:console.log("%1%")') ]
def setup_table(self, table): table.add_columns( 'name', ColumnBase(column_name='CustomResultFunction', field='people', row_result=self.badge, annotations={'people': Count('person__id')}, title='Send HTML'), ColumnBase(column_name='Range', field='people', row_result=self.range, hidden=True), ColumnBase(column_name='people', title='HTML generated in JS', field='people', render=[ { 'var': '%1%', 'column': 'people', 'html': '<span class="badge badge-primary">%1%</span>', 'function': 'Replace' }, ]), ) table.row_color('Range', ('GT1', 'table-danger'), ('LT1', 'table-warning')) table.sort('-people')
def setup_schema_tables(self, table): table.add_columns( 'table', 'size', ('rows', {'title': 'No. Rows (Approx)'}), ColumnBase(column_name='Download', render=[row_button('download_xls', '<i class="far fa-file-excel"></i>', button_classes='btn btn-outline-secondary btn-sm', )]), ColumnBase(column_name='Backup', render=[row_button('backup_schema', 'Backup', button_classes='btn btn-success btn-sm', )]) ) table.table_data = [{'table': s[0], 'size': s[1], 'rows': s[2]} for s in get_schema_tables(self.kwargs['schema'])] table.table_options['column_id'] = 0 table.sort('table') table.table_options['stateSave'] = False
def setup_table(self, table): table.add_columns( ColumnBase(column_name='cars', field='cars', calculated=True, aggregations={'cars': Sum('cars')}), ColumnBase(column_name='vans_sum', field='vans_s', calculated=True, aggregations={'vans_s': Sum('vans')}), ColumnBase(column_name='vans_min', field='vans_m', calculated=True, aggregations={'vans_m': Min('vans')}), )
def setup_table(table): table.add_columns( 'id', 'name', 'Tags', ColumnBase(column_name='people', field='people', annotations={'people': Count('person__id')}), ColumnLink(column_name='view_company', field='name', url_name='example2'), ) table.add_js_filters('tag', 'Tags')
def setup_schemas(self, table): table.add_columns( 'schema', 'size', ColumnLink( column_name='view_schema', link_ref_column='schema', url_name='gdrive_backup:schema_info', link_html='<button class="btn btn-sm btn-outline-dark">VIEW</button>' ), ColumnBase(column_name='Backup', render=[row_button('backup_schema', 'Backup', button_classes='btn btn-success btn-sm',)]) ) table.table_data = [{'schema': s[0], 'size': s[1]} for s in self.schemas] table.table_options['column_id'] = 0 table.sort('schema') table.table_options['stateSave'] = False
def setup_table(self, table): table.add_columns( 'id', ColumnBase(column_name='idi', title='without helper', field=['id', 'name'], render=[ { 'var': '%1%', 'column': 'idi:0', 'html': '<b>%1%</b> <i>%2%</i>', 'function': 'Replace' }, { 'var': '%2%', 'column': 'idi:1', 'function': 'Replace' }, ]), ColumnBase(column_name='idx', field=['id', 'name'], title='with helper', render=[ render_replace(html='<b>%1%</b> <i>%2%</i>', column='idx:0'), render_replace(var='%2%', column='idx:1'), ]), ColumnBase(column_name='BasicButton', render=[row_button('toggle_tag', 'toggle TAG1')]), ColumnBase(column_name='FormattedButton', render=[ row_button('toggle_tag', 'toggle TAG1', button_classes='btn %1% btn-sm', var='%1%', value=1, column='CompanyTags', choices=['btn-success', ''], function='ValueInColumn') ]), ColumnBase(column_name='Delete', render=[row_button('delete', 'Delete Row')]), self.TagsY(column_name='tags_raw'), ManyToManyColumn( column_name='CompanyTags', m2m_model=models.Tags, connecting_field='company', display_field='tag', html='<span class="badge badge-primary"> %1% </span>'), ColumnBase(column_name='people', field='people', annotations={'people': Count('person__id')}), ) table.ajax_data = False table.add_js_filters('tag', 'CompanyTags')
def setup_table(table): table.add_columns( CollapseButton(column_name='collapsed', field='collapsed'), '.level', '.id', '.person_id', ColumnBase(column_name='name', field='name', column_defs={'orderable': False}), 'first_name', 'surname', ) table.sort('id', 'level') table.add_js_filters('expand', 'level', id_column='id') # table.column('name').column_defs['orderable'] = False table.column('first_name').column_defs['orderable'] = False table.column('surname').column_defs['orderable'] = False table.column('collapsed').column_defs['orderable'] = False
def setup_table(table): table.add_columns( 'id', 'first_name', 'last_name', 'company_name', ColumnBase(column_name='seconds', field='seconds', render=[ { 'function': 'hhmm', 'column': 'seconds', 'var': '%1%' }, ], column_defs={'className': 'dt-right'}), ) table.table_options['scrollX'] = True table.add_plugin(ColumnTotals, {'seconds': {'sum': True}})
def setup_table(table): table.add_columns( ('id', { 'column_defs': { 'width': '30px' } }), 'name', 'Tags', ColumnBase(column_name='people', field='people', annotations={'people': Count('person__id')}), ColumnLink(column_name='view_company', field='name', url_name='example2'), ColumnLink( column_name='view_company_icon', link_ref_column='id', url_name='example2', width='10px', link_html= '<button class="btn btn-sm btn-outline-dark"><i class="fas fa-building"></i></button>' ), ) table.column('name').column_defs['orderable'] = False table.add_plugin(ColourRows, [{ 'column': 0, 'values': { '1': 'table-danger' } }]) table.ajax_data = False table.add_js_filters('tag', 'Tags') table.add_js_filters('totals', 'people', filter_title='Number of People', collapsed=False)
def setup_table(self, table): tags = list(models.Tags.objects.values_list('id', 'tag')) v_lookup = [] for t in tags: if t[0] % 2: v_lookup.append([t[0], [t[1], 'warning']]) else: v_lookup.append([t[0], [t[1], 'danger']]) table.add_columns( 'id', ColumnBase(column_name='idi', title='without helper', field=['id', 'name'], render=[ { 'var': '%1%', 'column': 'idi:0', 'html': '<b>%1%</b> <i>%2%</i>', 'function': 'Replace' }, { 'var': '%2%', 'column': 'idi:1', 'function': 'Replace' }, ]), ColumnBase(column_name='idx', field=['id', 'name'], title='with helper', render=[ render_replace(html='<b>%1%</b> <i>%2%</i>', column='idx:0'), render_replace(var='%2%', column='idx:1'), ]), ColumnBase(column_name='BasicButton', render=[row_button('toggle_tag', 'toggle TAG1')]), ColumnBase(column_name='FormattedButton', render=[ row_button('toggle_tag', 'toggle TAG1', button_classes='btn %1% btn-sm', var='%1%', value=1, column='CompanyTags', choices=['btn-success', ''], function='ValueInColumn') ]), ColumnBase(column_name='Delete', render=[row_button('delete', 'Delete Row')]), self.TagsY(column_name='tags_raw'), ManyToManyColumn( column_name='CompanyTags', field='tags__tag', model=models.Company, html='<span class="badge badge-primary"> %1% </span>'), ManyToManyColumn(column_name='Coloured', field='tags__tag', model=models.Company, lookup=v_lookup, render=[{ 'var': ['%1%', '%2%'], 'html': '<span class="badge badge-%2%"> %1% </span>', 'function': 'ReplaceLookup' }]), ColumnBase(column_name='people', field='people', annotations={'people': Count('person__id')}), ) table.ajax_data = False table.add_js_filters('tag', 'CompanyTags') table.add_plugin( ColumnTotals, { 'id': { 'css_class': 'text-danger', 'text': 'Total %id%', 'sum': 'to_fixed', 'decimal_places': 1 }, 'people': { 'sum': True } })
def setup_table(self, table): table.add_columns( ('id', { 'column_defs': { 'width': '30px' } }), 'name', 'Tags', ('dissolved', { 'choices': ['yes', 'no'] }), ColumnLink(column_name='peoplex', field=['id', 'name'], url_name='example2'), ColumnBase(column_name='people', field='people', annotations={'people': Count('person__id')}), ColumnLink(column_name='view_company', field=['id', 'name'], url_name='example2'), ColumnLink( column_name='view_company_icon', link_ref_column='id', url_name='example2', width='10px', link_html= '<button class="btn btn-sm btn-outline-dark"><i class="fas fa-building"></i></button>' ), 'reverse_tag', ManyToManyColumn( column_name='DirectTag', field='direct_tag__tag_direct', model=models.Company, html='<span class="badge badge-primary"> %1% </span>'), ) table.column('name').column_defs['orderable'] = False table.add_plugin(ColourRows, [{ 'column': 'id', 'values': { '1': 'table-danger' } }]) table.ajax_data = False table.add_js_filters('tag', 'Tags') table.add_js_filters('totals', 'people', filter_title='Number of People', collapsed=False) add_save_filters(table, self.request.user) # table.add_js_filters('tag', 'DirectTag') table.table_options['row_href'] = row_link('example2', 'id') table.table_options['no_col_search'] = True table.table_options['pageLength'] = '22' # table.table_options['scrollX'] = True # table.table_options['row_href'] = [render_replace(column='id', html='javascript:console.log("%1%")')] table.add_plugin(ColumnTotals, {'id': { 'sum': 'over1000' }}, template='add_sum_calc.html')