'Internally used method to get the data from the database
If the list of fields is provided then only these will be returned
otherwise all fields on the table will be returned
Automatically the id field will be hidden, and if
hideComments is true then the comments field will also be hidden.
If a groupby field is provided then this will be used as the sort
criteria, otherwise it will sort by the first field
The returned records are stored in the records property.'

def select(self):

    resource = self.resource
    list_fields = self.list_fields
    if (not list_fields):
        fields = resource.readable_fields()
        for field in fields:
            if (field.type == 'id'):
                fields.remove(field)
            if (self.hideComments and (field.name == 'comments')):
                fields.remove(field)
        if (not fields):
            fields = [table.id]
        list_fields = [f.name for f in fields]
    else:
        indices = s3codec.S3Codec.indices
        list_fields = [f for f in list_fields if (f not in indices)]
    filter = current.response.s3.filter
    if (filter is not None):
        resource.add_filter(filter)
    orderby = self.report_groupby
    table = resource.table
    rfields = resource.resolve_selectors(list_fields)[0]
    fields = [f for f in rfields if f.show]
    headers = [f.label for f in rfields if f.show]
    if (orderby != None):
        orderby = fields[0].field
    self.records = resource.select(list_fields, limit=None, orderby=orderby, as_rows=True)
    self.labels = headers
    self.fields = fields
