'Internally used method to format the data from the database
This will extract the data from the returned records list.
If there is a groupby then the records will be grouped by this field.
For each new value the groupby field will be placed in a list of
its own. This will then be followed by lists of the records that
share this value
If there is no groupby then the result is a simple matrix of
rows by fields'

def getData(self):

    data = []
    currentGroup = None
    subheadingList = []
    rowNumber = 1
    for item in self.records:
        row = []
        if (self.report_groupby != None):
            groupData = s3_represent_value(self.report_groupby, record=item, strip_markup=True, non_xml_output=True)
            if (groupData != currentGroup):
                currentGroup = groupData
                data.append([groupData])
                subheadingList.append(rowNumber)
                rowNumber += 1
        for field in self.fields:
            if (self.report_groupby != None):
                if (field.label == self.report_groupby.label):
                    continue
            if field.field:
                text = s3_represent_value(field.field, record=item, strip_markup=True, non_xml_output=True, extended_comments=True)
            if ((text == '') or (not field.field)):
                tname = field.tname
                fname = field.fname
                if (fname in item):
                    text = item[fname]
                elif ((tname in item) and (fname in item[tname])):
                    text = item[tname][fname]
                else:
                    text = ''
            row.append(text)
        data.append(row)
        rowNumber += 1
    return (subheadingList, data)
