Page 1 of 1
populating a datagrid fails in simulator
Posted: Sun Nov 14, 2010 5:06 pm
by stanier25
Hi All,
I'm quite new to liveCode so this may well be that I'm missing something obvious! I've got an app the pulls data from a web service, drops it into a field, splits it into chunks then populates a datagrid with the chunks. All works fine in Livecode itself but when I test this in the iPhone simulator (ios 4.1) the datagrid fails to get populated. I can see the data coming in from the web service so I've narrowed the problem down to the data actually being added to the datagrid - I have a separate button that puts an empty array into the datagrid and this fails as well.
The datagrid itself displays fine in the simulator - i.e. if I populate the datagrid in livecode, save the app then run it in the simulator the data shows up.
I need to use a datagrid because the data contains icons as well as text so it appears to be the best control to lay out the kind of data I'm working on.
Any suggestions gratefully received!
Re: populating a datagrid fails in simulator
Posted: Sat Nov 20, 2010 2:38 am
by edmerckx99
i am having this problem as well, is not possible as of yet?
Re: populating a datagrid fails in simulator
Posted: Sat Nov 20, 2010 10:46 pm
by ctflatt
Check the other DG post here...
Re: populating a datagrid fails in simulator
Posted: Tue Feb 15, 2011 9:29 pm
by murmac
Hi Stanier,
could you post here an example code to consume a SOAP WS in livecode? I have 4 parameters in my WS with one method, but I don“t know how to implement a request and response code.
Thanks
stanier25 wrote:Hi All,
I'm quite new to liveCode so this may well be that I'm missing something obvious! I've got an app the pulls data from a web service, drops it into a field, splits it into chunks then populates a datagrid with the chunks. All works fine in Livecode itself but when I test this in the iPhone simulator (ios 4.1) the datagrid fails to get populated. I can see the data coming in from the web service so I've narrowed the problem down to the data actually being added to the datagrid - I have a separate button that puts an empty array into the datagrid and this fails as well.
The datagrid itself displays fine in the simulator - i.e. if I populate the datagrid in livecode, save the app then run it in the simulator the data shows up.
I need to use a datagrid because the data contains icons as well as text so it appears to be the best control to lay out the kind of data I'm working on.
Any suggestions gratefully received!
Re: populating a datagrid fails in simulator
Posted: Sat Jun 29, 2013 9:56 am
by mvillion
Hi
This was driving me bananas.
Solution
On card 1 of your stack place a datagrid and hide it.
It will then work.
Go figure.
Re: populating a datagrid fails in simulator
Posted: Mon Apr 14, 2014 4:05 am
by altschuler.jon
I'm having similar problem: datagrid being populated fine in LiveCode, but fails in iOS simulator.
The data is coming from an API.
I have tried the recommendation of putting a datagrid on card 1 and hiding it, but that didn't work.
Any recommendations for iOS apps that want to use a datagrid?
Thanks,
Jon
Re: populating a datagrid fails in simulator
Posted: Mon Apr 14, 2014 8:46 am
by Jellicle
altschuler.jon wrote:
I have tried the recommendation of putting a datagrid on card 1 and hiding it, but that didn't work.
I'm not surprised - that's voodoo.
Tell us more about the format of the data, the kind of data grid and perhaps show us the script you are trying to debug. It's hard to help when someone just says "it doesn't work".
Gerry
Re: populating a datagrid fails in simulator
Posted: Mon Apr 14, 2014 11:17 am
by peramangk
When using the simulator, it's handy to use 'answer' commands in troublesome scripts to report back the value of variables, which arm of an 'if' statement is being followed or anything else that might track down the problem.
Re: populating a datagrid fails in simulator
Posted: Mon Apr 14, 2014 6:46 pm
by altschuler.jon
When you open the card with the datagrid, i load the API url:
Code: Select all
on OpenCard
put "there is a URL here but I can't seem to include in the forum post" into theURL
load URL theURL with message "FileIsDoneDownloading"
end OpenCard
When the file is down loading, i manipulate the array to be cleaner for the datagrid. The repeat loop could be my problem, but I haven't found a better way to get the array into the datagrid successfully.
Code: Select all
on FileIsDoneDownloading pURL, pURLStatus
if pURLStatus is "cached" then
## set the text of field "fld_result" to URL pURL
put URL pURL into tAllCoins
## put the results of the API call into an array
put jsonToArray(tAllCoins, true) into gCoinListArray
put gCoinListArray[results][collection1] into gCoinListArray
## put the array into dataGrid format
repeat with x = 1 to (item 2 of line 1 of the extents of gCoinListArray)
put gCoinListArray[x]["coinID"]["text"] into gCoinListData[x]["coinID"]
put gCoinListArray[x]["icon"]["src"] into gCoinListData[x]["icon"]
end repeat
set the dgData of group "dgCoinList" to gCoinListData
## clear cache when done
unload url pURL
else
put libURLErrorData(pURL) into theError
set the text of field "fld_error" to "An error occurred:" && theError & "."
end if
end FileIsDoneDownloading
In the datagrid behavior script:
Code: Select all
on FillInData pDataArray
set the text of field "coinID" of me to pDataArray["coinID"]
set the filename of image "icon" of me to pDataArray["icon"]
end FillInData
Re: populating a datagrid fails in simulator
Posted: Mon Apr 14, 2014 10:56 pm
by altschuler.jon
OK, problem solved, sort of.
Basically I was using the load command with a callback script that uses "pURLStatus" which apparently is only useable on desktop. On mobile you need to use a callback script of "on urlProgress".
FACEPALM.
J