it sounds like you don't even need multiple columns, you just need a title and a subtitle. more complex cells you can design yourself, using the content_view.
This example shows the four cell styles -- value1, value2, subtitle, and default. For bonus points, you would have the tableview_cell_for_row , etc, actually look up durectly from your sql database .
import ui,sys
PY3 = sys.version_info[0] >= 3
if PY3:
basestring = str
class DetailTextDataSource(ui.ListDataSource):
def __init__(self, items, style):
self.style=style
ui.ListDataSource.__init__(self,items)
def tableview_cell_for_row(self,tv,section,row):
item = self.items[row]
cell = ui.TableViewCell(self.style)
cell.text_label.number_of_lines = self.number_of_lines
if isinstance(item, dict):
cell.text_label.text = item.get('title', '')
try:
cell.detail_text_label.text = item.get('subtitle', '')
except AttributeError:
pass
img = item.get('image', None)
if img:
try:
if isinstance(img, basestring):
cell.image_view.image = ui.Image.named(img)
elif isinstance(img, ui.Image):
cell.image_view.image = img
except AttributeError:
pass
accessory = item.get('accessory_type', 'none')
cell.accessory_type = accessory
elif isinstance(item,tuple):
cell.text_label.text = str(item[0])
cell.detail_text_label.text = str(item[1])
else:
cell.text_label.text = str(item)
if self.text_color:
cell.text_label.text_color = self.text_color
if self.highlight_color:
bg_view = ui.View(background_color=self.highlight_color)
cell.selected_background_view = bg_view
if self.font:
cell.text_label.font = self.font
return cell
items=[{'title':'Strawberries','subtitle':'3.99','image':'plf:Enemy_Ladybug'},
{'title':'Blueberries','subtitle':'2.99','image':'plf:Enemy_Snail_shell'},
{'title':'Honey','subtitle':'4.50','image':'plf:Enemy_Bee'},
{'title':'Fresh fish','subtitle':'6/lb','image':'plf:Enemy_FishGreen'},
]
mainview=ui.View(frame=(0,0,1024,768))
S1=DetailTextDataSource(items,'value1')
t=ui.TableView(frame=(0,0,300,600))
t.data_source=S1
t.delegate=S1
mainview.add_subview(t)
S2=DetailTextDataSource(items,'value2')
t2=ui.TableView(frame=(310,0,200,600))
t2.data_source=S2
t2.delegate=S2
mainview.add_subview(t2)
S3=DetailTextDataSource(items,'subtitle')
t3=ui.TableView(frame=(520,0,200,600))
t3.data_source=S3
t3.delegate=S3
mainview.add_subview(t3)
S4=DetailTextDataSource(items,'default')
t4=ui.TableView(frame=(740,0,200,600))
t4.data_source=S4
t4.delegate=S4
mainview.add_subview(t4)
mainview.present()