send column data to optionmenu (SOLVED)
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
send column data to optionmenu (SOLVED)
i will try to make my question simple.
i have a datagrid with data in card-1,and i have 1 option menu into card-3
I need to get the column data from the datagrid (customer_id) of card-1 to the pChosenItem into card-3
i have read the http://lessons.runrev.com/s/lessons/m/d ... -or-column but still is hard to figure out how..
thank you.
i have a datagrid with data in card-1,and i have 1 option menu into card-3
I need to get the column data from the datagrid (customer_id) of card-1 to the pChosenItem into card-3
i have read the http://lessons.runrev.com/s/lessons/m/d ... -or-column but still is hard to figure out how..
thank you.
Last edited by vedus on Thu Dec 05, 2013 6:11 pm, edited 1 time in total.
Re: send column data to option menu
Hi vedus,
You want go get ALL the data from every column named "customer_id" from the datagrid?
Preferrably as a CR delimited list? Is that correct?
And you want to put this into your option button as menuitems?
Is that also correct?
OK, when do you want to do this?
"opencard", "mouseup" etc.?
Basically you need to loop through "the dgdata of grp xyz" and collect all the "customer_id" keys
Give some more info and we will solve this!
Best
Klaus
Datagrid questions are rarely simple questions!vedus wrote:i will try to make my question simple.

OK, get it.vedus wrote:i have a datagrid with data in card-1,and i have 1 option menu into card-3
Sorry, don't get this?vedus wrote:I need to get the column data from the datagrid (customer_id) of card-1 to the pChosenItem into card-3

You want go get ALL the data from every column named "customer_id" from the datagrid?
Preferrably as a CR delimited list? Is that correct?
And you want to put this into your option button as menuitems?
Is that also correct?
OK, when do you want to do this?
"opencard", "mouseup" etc.?
Basically you need to loop through "the dgdata of grp xyz" and collect all the "customer_id" keys

Give some more info and we will solve this!
Best
Klaus
Re: send column data to option menu
sorry for the delay..
the datagrid is populate like this
here is the start Up
below code is on card-1 with datagrid
then to make the query i use this code.
Then i want to use the filtered data from dbWhere and use it in the option menu that is on card-3;)
the datagrid is populate like this
here is the start Up
Code: Select all
on preOpenStack
-- use switch with "the environment" property to determine if the app is running on mobile or in development
switch the environment
-- if its development, do pretty much what andre was already doing
case "development"
-- set default folder
set the itemdel to "/"
set the defaultfolder to item 1 to -2 of the effective filename of this stack
put "databin.sqlite" into tDatabase -- using a variable to store the path to the database file rather than using the path directly in revopendatabase
break
case "mobile"
-- if its mobile, point to where the database should be.
-- the documents folder is readable and writable.
-- the engine folder path is only readable.
-- when the file was included using the "copy files" pane
-- of the standalone settings, it will end up in the engine folder, next to the executable
-- but since the engine folder isn't writable you have to copy it to the right place if its not already there.
put specialfolderpath("documents") & "/databin.sqlite" into tDatabase
-- see if the database is already in the documents folder
-- if not, copy it there from the engine folder
if there is not a file tDatabase then
put URL ("binfile:" & specialfolderpath("engine") & "/databin.sqlite") into URL ("binfile:" & tDatabase)
end if
break
end switch
-- since aagDBLib should now be a substack you don't hvae to specify a
-- path to the file. Just the stack name.
start using stack "aagDBLib"
-- open the database using the variable tDatabase to point to the file
-- if its on mobile the tdatabase will point to the file in specialfolderpath(documents)
-- otherwise it will point to a file sitting next to the demo stack.
get revOpenDatabase("sqlite",tDatabase,,,)
-- catch any errors as andre already did.
if it is a number then
dbSetDefaultConnectionID it
else
answer error it
end if
end preOpenStack
Code: Select all
#Get data from sqlite
put dbGet("customers") into myArray
set dgdata of control "datagrid" to myArray
Code: Select all
#filter the data from sqlite
dbWhere "customer_id","first_name","last_name"
put dbGet("customers") into myRecordsA
Re: send column data to option menu
Hi vedus,
sorry, no idea how your database library works, what does this mean:
...
dbWhere "customer_id","first_name","last_name"
put dbGet("customers") into myRecordsA
...
And what database field exactly do you want to display in your option menu?
Still don't get it, and unfortunately you did not answer any of my questions!
Best
Klaus
sorry, no idea how your database library works, what does this mean:
...
dbWhere "customer_id","first_name","last_name"
put dbGet("customers") into myRecordsA
...
And what database field exactly do you want to display in your option menu?
Still don't get it, and unfortunately you did not answer any of my questions!

Best
Klaus
Re: send column data to option menu
hi claus
i use the dblib from Andre for my database.
the dbWhere is the filter query command like this (SELECT * FROM customers WHERE name = 'name';)
and the with dbget i get the whole table.
so with below code i filter my database and i get the "customer_id" from table "customers" as array.
about your questions is
1:) all the data from specific column "customer_id"
2:) i want to put it in the option button as menuitems
3:) i prefer the opencard
hi Klaus and ty for your patienceKlaus wrote:Hi vedus,
sorry, no idea how your database library works, what does this mean:
...
dbWhere "customer_id","first_name","last_name"
put dbGet("customers") into myRecordsA
...
And what database field exactly do you want to display in your option menu?
Still don't get it, and unfortunately you did not answer any of my questions!![]()
Best
Klaus

i use the dblib from Andre for my database.
the dbWhere is the filter query command like this (SELECT * FROM customers WHERE name = 'name';)
and the with dbget i get the whole table.
so with below code i filter my database and i get the "customer_id" from table "customers" as array.
Code: Select all
dbWhere "customer_id"
put dbGet("customers") into myRecordsA
1:) all the data from specific column "customer_id"
2:) i want to put it in the option button as menuitems
3:) i prefer the opencard
Re: send column data to option menu
Hi vedus,
OK, what format is myRecordsA?
All you need is in this variable, but I have no idea if this is an array or a CR delimited list?
See above we only need to find out what XXX is and that's it
Best
Klaus
aha!vedus wrote:Code: Select all
dbWhere "customer_id" put dbGet("customers") into myRecordsA
OK, what format is myRecordsA?
All you need is in this variable, but I have no idea if this is an array or a CR delimited list?
Then 3. use an "opencard" handler to fill the button 2.-> set the text of btn "you option menu" to 1. XXXvedus wrote:1:) all the data from specific column "customer_id"
2:) i want to put it in the option button as menuitems
3:) i prefer the opencard
See above we only need to find out what XXX is and that's it

Best
Klaus
Re: send column data to option menu
dbGet(tableName) returns a nested array where the first level is a number that will go from 1 to the number of records retrieved. The second level is an array of the field names from the schema and their values.
something like this bellow
something like this bellow
Code: Select all
tRecordsA[1]["id"] = 1
tRecordsA[1]["first_name"] = andre
tRecordsA[1]["last_name"] = garzia
tRecordsA[1]["email"] = andre@andregarzia.com
Re: send column data to option menu
OK, given you need all the data from ID, you need to use a repat loop and collect the data:
You get the picture
Best
Klaus
Code: Select all
...
repeat for each key tKey in tRecordsA
put tRecordsA[tKey]["id"] & CR after tOptionMenuList
end repeat
## Delete trailing CR
delete char -1 of tOptionMenuList
## Fill option button:
set the text of btn "your option button here..." to tOptionMenuList
...

Best
Klaus
Re: send column data to option menu
yes now i get it,i will post the results 

Re: send column data to option menu
here is the solution after klaus help 
With dbcolumns i get the columns i want from database file
the above code is working perfect in the option menu.
last question is.
with put myRecords[tKey]["first_name"] & CR after tOptionMenuList we pass the one column from the array
it is possible we pass 2 columns?
i try to put
but i get empty..

With dbcolumns i get the columns i want from database file
Code: Select all
#fill the data
dbcolumns "first_name,last_name"
put dbGet("customers") into myRecords
--repeat
repeat for each key tKey in myRecords
put myRecords[tKey]["first_name"] & CR after tOptionMenuList
end repeat
## Delete trailing CR
delete char -1 of tOptionMenuList
## Fill option button:
#for unicode text
set the unicodetext of btn "myopt" to uniencode(tOptionMenuList,"utf8")
last question is.
with put myRecords[tKey]["first_name"] & CR after tOptionMenuList we pass the one column from the array
it is possible we pass 2 columns?
i try to put
Code: Select all
repeat for each key tKey in (the keys of myRecords)
put myRecords[tKey]["first_name"]["last_name"]& CR after tOptionMenuList
Re: send column data to option menu
Hi vedus,
THAT key "myRecords[tKey]["first_name"]["last_name"]" does not exist!
Do this:
Best
Klaus
Code: Select all
repeat for each key tKey in (the keys of myRecords)
put myRecords[tKey]["first_name"]["last_name"]& CR after tOptionMenuList

Do this:
Code: Select all
repeat for each key tKey in (the keys of myRecords)
put myRecords[tKey]["first_name"] && myRecords[tKey]["last_name"]& CR after tOptionMenuList
Klaus
Re: send column data to option menu
thank you and really appreciate your help with my code
done and the app is working perfect time to deploy it in the ipad

done and the app is working perfect time to deploy it in the ipad
