'Generate a datatable in the organisations custom page'

@staticmethod
def _table(name, resource, field_list, limit=10, orderby='name'):

    data = resource.select(field_list, limit=None, orderby=orderby, count=True, represent=True)
    rfields = data['rfields']
    records = data['rows']
    numrows = len(records)
    rows = []
    cols = []
    for rfield in rfields:
        colname = rfield.colname
        cols.append({'name': colname, 'label': rfield.label})
        for i in xrange(numrows):
            if (len(rows) == i):
                rows.append([])
            rows[i].append(records[i][colname])
    options = json.dumps({'deferLoading': data['numrows'], 'columnDefs': [{'targets': [0]}], 'columns': [{'name': col['name'], 'visible': False} for col in cols], 'dom': 'rifpl<"dataTable_table"t>p', 'pageLength': limit, 'processing': True})
    script = ("S3.dataTablesInstances.push({'options':%s})" % XML(options))
    current.response.s3.js_global.append(script)
    table = Storage(cols=cols, rows=rows)
    return table
