def __init__(self, header, aggregate_fn, *columns, **kwargs): """ Args: :param header: The column header. :param aggregate_fn: The function used to aggregate the individual values into a single value. :param columns: List of columns (instances of sqlagg.BaseColumn). Kwargs: :param format_fn=None: Function to apply to value before display. Useful for formatting and sorting. See corehq.apps.reports.util.format_datatables_data """ self.aggregate_fn = aggregate_fn format_fn = kwargs.pop('format_fn', None) if 'sortable' not in kwargs: kwargs['sortable'] = True if kwargs['sortable'] and 'sort_type' not in kwargs: kwargs['sort_type'] = DTSortType.NUMERIC format_fn = format_fn or format_data self.header_group = kwargs.pop('header_group', None) self.data_tables_column = DataTablesColumn(header, **kwargs) if self.header_group: self.header_group.add_column(self.data_tables_column) self.view = sqlagg.AggregateColumn(aggregate_fn, *columns) super(AggregateColumn, self).__init__(format_fn=format_fn)
def __init__(self, header, aggregate_fn, columns, format_fn=None, slug=None, **kwargs): """ Args: :param header: The column header. :param aggregate_fn: The function used to aggregate the individual values into a single value. :param columns: List of columns (instances of sqlagg.BaseColumn). Kwargs: :param format_fn=None: Function to apply to value before display. Useful for formatting and sorting. See corehq.apps.reports.util.format_datatables_data :param slug=None: Unique ID for the column. If not supplied assumed to be slugify(header). This is used by the Report API. :param sortable: Indicates if the column should be sortable. If true and no format_fn is provided then the default datatables format function is used. Defaults to True. :param sort_type: See corehq.apps.reports.datatables.DTSortType """ self.aggregate_fn = aggregate_fn self.slug = slug or slugify(header) if 'sortable' not in kwargs: kwargs['sortable'] = True if kwargs['sortable'] and 'sort_type' not in kwargs: kwargs['sort_type'] = DTSortType.NUMERIC format_fn = format_fn or format_data self.header = header self.header_group = kwargs.pop('header_group', None) self.data_tables_column = DataTablesColumn(header, **kwargs) if self.header_group: self.header_group.add_column(self.data_tables_column) self.view = sqlagg.AggregateColumn(aggregate_fn, *columns) super(AggregateColumn, self).__init__(format_fn=format_fn)
def __init__(self, header, aggregate_fn, *columns, **kwargs): """ Args: :param header: The column header. :param aggregate_fn: The function used to aggregate the individual values into a single value. :param columns: List of columns (instances of sqlagg.BaseColumn). """ self.aggregate_fn = aggregate_fn self.header_group = kwargs.pop('header_group', None) self.data_tables_column = DataTablesColumn(header, **kwargs) if self.header_group: self.header_group.add_column(self.data_tables_column) self.view = sqlagg.AggregateColumn(aggregate_fn, *columns)