I have adjusted the content so it matches the db file
The way I made it is like the class: ButtonsBirds.lua -(inside the Classes folder), inserts the button args into the table mySqlView trough the function engineResponse() --this can be like if I press the Red bodycolour button it will send “BODYCOLOUR = ‘Red’” or in your way: table.insert(birdAttributesQuery, unpack({ key = “ART”, value = “Andefamilien”, condition = “AND” })) , right?
OK, I will be extremely glad if you can help with this “little thing” that stops my whole project Rob
This is not with your piece of code because the function functionSqlView() produces the right statements when you click one of the buttons at the bottom. I have been reading one of your replies in another forum post where you discuss where to put the different components of the tableView structure when dealing with composer and going back and forth through composer pages/scenes.
So I rearranged my code and took the onRowrender function from will show over to create scene then it started to re-render my rows again
Anyway, I think my real q here is: how do I sort and show the data I now have to the display?
I think the problem lies at line 61 in playGame file
When this is sorted out, I will use your approach on the functionSqlView function
You are right, when I check the proj sandbox and it´s nothing there? but it fires up the db that lies in the root dir: ‘Birds.sqlite’ in line 250 (where I iterate over the sql statement), in playGame if I´m not mistaken
but I´m not shure
If you like to se how I like it to be you can first run the code in sim and see (you see all entries), then you can put i.e. this statement in line 245 right before count = 0:
[LUA]“SELECT * FROM birds WHERE COLOR1 = ‘Sort’”[/LUA]
and save. what you now see in the simulator is a narrow selection just like I want right?
I will like to thank you, Rob for all help you have done for me
Everything is working nicely now. Here´s the trick from your code that helped me out
[LUA]
function functionSqlView()
local sql = nil
tableView:deleteAllRows()
local counter = 1
local res = {}
– NOW WE BUILD THE SQL QUERY IN A FORLOOP FROM THE mySqlView TABLE, INSERTED FROM THE SUBBUTTONS VALUES
sql = "SELECT * FROM birds WHERE "
for k, v in ipairs(mySqlView) do
sql = sql … v … " "
if counter < #mySqlView then
sql = sql … " AND "
end
counter = counter + 1
end
dbTable = {} – START WITH A FRESH TABLE
count = 0 – AND FRESH COUNTER
– PREPARE THE ROWS SELLECTION BASED ON THE DATABASE ROWS THROUGH THE SQL QUERY
for row in db:nrows( sql ) do
count = count +1
dbTable[count]={}
dbTable[count].NAME = row.NAME
dbTable[count].LATIN = row.LATIN
dbTable[count].INFO = row.INFO
end
– STYLING FOR THE ROWS ON SCREEN
for i = 1, #dbTable do
local isCategory = false
local rowHeight = 95
local rowColor = {
default = { colorConverter(114, 72, 30, 0) },
}
local lineColor = { colorConverter(20, 20, 0, 0) }
– Insert the row into the tableView
tableView:insertRow
{
rowHeight = rowHeight,
rowColor = rowColor,
lineColor = lineColor,
}
end
return true
end