Getting values out of DataGrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Getting values out of DataGrid
Hello,
I have problems getting values out of a Datagrid.
I have this simple DataGrid
col1 col2
Club Plaats (=column title)
DOVO Assen
Roda Raalte
ACV Assen
Now I want to get the bold values based on the Plaats = Assen.
I already have this code, but than I only get the first value, not both values.
put text of field "resultpost" into tNaam2
repeat for each line theLine in theData
dispatch "FindIndex" to group "tabel" with "plaats", tNaam2
end repeat
put the result into theIndex
put the dgDataOfLine[theIndex] of group "tabel" into theMessageB
put theMessageB["club"] into pZoekenoppostcode
put pZoekenoppostcode into field "post"
Can someone help me out?
I have problems getting values out of a Datagrid.
I have this simple DataGrid
col1 col2
Club Plaats (=column title)
DOVO Assen
Roda Raalte
ACV Assen
Now I want to get the bold values based on the Plaats = Assen.
I already have this code, but than I only get the first value, not both values.
put text of field "resultpost" into tNaam2
repeat for each line theLine in theData
dispatch "FindIndex" to group "tabel" with "plaats", tNaam2
end repeat
put the result into theIndex
put the dgDataOfLine[theIndex] of group "tabel" into theMessageB
put theMessageB["club"] into pZoekenoppostcode
put pZoekenoppostcode into field "post"
Can someone help me out?
Re: Getting values out of DataGrid
Dag Ed,
what you see on the monitor, the datagrid, is only the visual representation of the actual data, which you need to search!
"FindIndex" will always only find one entry.
Do this:
Groetjes
Klaus
what you see on the monitor, the datagrid, is only the visual representation of the actual data, which you need to search!
"FindIndex" will always only find one entry.
Do this:
Code: Select all
...
## This is what you are looking for, right?
put text of field "resultpost" into tNaam2
## Get the actual data
put the dgdata of grp "tabel" into tData
## Now loop through all KEYS of this array and check them:
repeat for each key tKey in tData
if tData[tKey]["plaats"] = tNaam2 then
## Collect desired values:
put tData[tKey]["club"] & CR after tListOfFoundValues
end if
end repeat
## Delete trailing CR
delete char -1 of tListOfFoundValues
put tListOfFoundValues into fld "post"
...
Klaus
Re: Getting values out of DataGrid
Thank Klaus,
That worked great.
You make it look so easy!
That worked great.
You make it look so easy!
Re: Getting values out of DataGrid
Grag gedaan
A day too late, but anyway:
Sinterklaas Kapoentje
Doe iets in mijn schoentje
Doe iets in mijn laarsje
Dank U Sinterklaasje!
A day too late, but anyway:
Sinterklaas Kapoentje
Doe iets in mijn schoentje
Doe iets in mijn laarsje
Dank U Sinterklaasje!
Re: Getting values out of DataGrid
Haha!
I got from Sinterklaas new socks with my name on it, how cool is that?
I got from Sinterklaas new socks with my name on it, how cool is that?
Re: Getting values out of DataGrid
That is VERY cool!
Re: Getting values out of DataGrid
Man, I'm so happy with it!
I don't really want to make another post, but I still have one problem with my stack. Everytime I open it, it is focussing on the first field. I already put some "focus on nothing" in it but nothing seems to work.
Can you have a look at it:
www dropbox com / s / m839lf68tolvi44 / VoetbalNavi1 . 6 . livecode
I don't really want to make another post, but I still have one problem with my stack. Everytime I open it, it is focussing on the first field. I already put some "focus on nothing" in it but nothing seems to work.
Can you have a look at it:
www dropbox com / s / m839lf68tolvi44 / VoetbalNavi1 . 6 . livecode
Re: Getting values out of DataGrid
Hi Ed,
To your problem, add this to the "opencard" or "openstack" script:
Play a bit with the time until it works for you...
This is neccessary, since you cannot "turn off" the default behavior of Livecode,
which IS to focus on the first field on a card everytime you go to that card.
Best
Klaus
yes, I understand that, socks with your name on them IS definitively cool!eddje16 wrote:Man, I'm so happy with it!
To your problem, add this to the "opencard" or "openstack" script:
Code: Select all
on openCard
send "focus on nothing" to me in 5 millisecs
end openCard
This is neccessary, since you cannot "turn off" the default behavior of Livecode,
which IS to focus on the first field on a card everytime you go to that card.
Best
Klaus
Re: Getting values out of DataGrid
I know!
Jealous?
Your solution worked.....of course..
Next problem is with GPS. It won't work on my Android device.
try
mobileStartTrackingSensor "location", true
put mobileSensorReading("location", true) into tLocation
mobileStopTrackingSensor "location"
set the itemdelimiter to comma
if the number of items in tLocation = 3 then
put item 1 of tLocation into pLat
put item 2 of tLocation into pLon
end if
end try
Is it the device itself or the code?
Jealous?
Your solution worked.....of course..
Next problem is with GPS. It won't work on my Android device.
try
mobileStartTrackingSensor "location", true
put mobileSensorReading("location", true) into tLocation
mobileStopTrackingSensor "location"
set the itemdelimiter to comma
if the number of items in tLocation = 3 then
put item 1 of tLocation into pLat
put item 2 of tLocation into pLon
end if
end try
Is it the device itself or the code?
Re: Getting values out of DataGrid
Hi Ed,
Did you check if the device has a "sensor" with "mobileSensorAvailable"?
Best
Klaus
A bit!eddje16 wrote:Jealous?
Hm, since I do not develop for mobile I can only guess.eddje16 wrote:Next problem is with GPS. It won't work on my Android device.Is it the device itself or the code?Code: Select all
... try mobileStartTrackingSensor "location", true put mobileSensorReading("location", true) into tLocation mobileStopTrackingSensor "location" set the itemdelimiter to comma if the number of items in tLocation = 3 then put item 1 of tLocation into pLat put item 2 of tLocation into pLon end if end try ...
Did you check if the device has a "sensor" with "mobileSensorAvailable"?
Best
Klaus
Re: Getting values out of DataGrid
Thought so!
Yes, the sensor is available, I checked it.
Yes, the sensor is available, I checked it.
Re: Getting values out of DataGrid
Ah, OK.
Maybe you should post your question right to the ANDROID forum (Hint, Hint!)
Maybe you should post your question right to the ANDROID forum (Hint, Hint!)