'Method to render the data into a json object
@param totalrows: The total rows in the unfiltered query.
@param displayrows: The total rows in the filtered query.
@param id: The id of the table for which this ajax call will
respond to.
@param draw: An unaltered copy of draw sent from the client used
by dataTables as a draw count.
@param attr: dictionary of attributes which can be passed in
dt_action_col: The column where the action buttons will be placed
dt_bulk_actions: list of labels for the bulk actions.
dt_bulk_col: The column in which the checkboxes will appear,
by default it will be the column immediately
before the first data item
dt_group_totals: The number of record in each group.
This will be displayed in parenthesis
after the group title.'

def json(self, totalrows, displayrows, id, draw, stringify=True, **attr):

    flist = self.colnames
    action_col = attr.get('dt_action_col', 0)
    if (action_col != 0):
        if ((action_col == (-1)) or (action_col >= len(flist))):
            action_col = (len(flist) - 1)
        flist = ((flist[1:(action_col + 1)] + [flist[0]]) + flist[(action_col + 1):])
    bulkActions = attr.get('dt_bulk_actions', None)
    bulkCol = attr.get('dt_bulk_col', 0)
    if bulkActions:
        if (bulkCol > len(flist)):
            bulkCol = len(flist)
        flist.insert(bulkCol, 'BULK')
        if (bulkCol <= action_col):
            action_col += 1
    return self.aadata(totalrows, displayrows, id, draw, flist, action_col=action_col, stringify=stringify, **attr)
