I have created a sqlite database and strictly following the Corona University Tutorial I am unable to populate the table.
The table shows up with the proper number of rows (based on the size of the table) It performs as expected.
I tested the for loop with print statements to see if the information was being imported from the database and like a charm all fields are populating to the terminal just fine.
inside the onRowRender function I attempted to print the values using row.params.<variable> as well as a simple row.<variable> and I get nothing, just like the table.
So the values are not being passed to the onRowRender function as far as I can tell. . . But not sure what the issue is.
Any help would be great.
Thanks
[lua]
– SQL TABLE – CREATE TABLEVIEW WIDGET
local table_options = {
top = _H * 0.1,
height = _H * 0.8,
backgroundColor = { 0.8, 0.8, 0.8 },
onRowRender = onRowRender,
}
local tableView = widget.newTableView( table_options)
– SQL TABLE – RETRIEVE DATA FROM DATABASE
for row in db:nrows(“SELECT * FROM input”) do
------------------------------------------------
– TESTING READING OF DATABASE ELEMENTS
print(row.id)
print(row.capture)
print(row.timeDate)
------------------------------------------------
--parameters for lua table
local rowParams = {
id = row.id,
capture = row.capture,
timeDate = row.timeDate,
}
– add tableview row
tableView:insertRow(
{
rowHeight = 50,
params = rowParams,
}
)
end
---------------------------------------------------------------------------------
– SQL TABLE – HANDLE TABLEVIEW RENDERING
---------------------------------------------------------------------------------
local function onRowRender ( event )
local row = event.row
print(row.id)
print(row.capture)
print(row.timeDate)
– common row elements
local font = native.systemFont
local fontSize = 24
local rowHeight = row.height / 2
– display.newText options
local options_id = {
parent = row,
text = row.params.id,
x = 50,
y = rowHeight,
font = font,
fontSize = fontSize,
}
– add row objects
row.id = display.newText( options_id )
row.id.anchorX = 0
row.id:setFillColor( 1, 0, 0 )
– display.newText options
local options_capture = {
parent = row,
text = row.params.capture,
x = 100,
y = rowHeight,
font = font,
fontSize = fontSize,
}
– add row objects
row.capture = display.newText( options_capture )
row.capture.anchorX = 0
row.capture:setFillColor( 1, 0, 0 )
– add row objects
row.id = display.newText( options_id )
row.id.anchorX = 0
row.id:setFillColor( 1, 0, 0 )
– display.newText options
local options_timeDate = {
parent = row,
text = row.params.timeDate,
x = 200,
y = rowHeight,
font = font,
fontSize = fontSize,
}
– add row objects
row.timeDate = display.newText( options_timeDate )
row.timeDate.anchorX = 0
row.timeDate:setFillColor( 1, 0, 0 )
end[/lua]