Reference DataGrid or Data Array?
Posted: Fri Jul 17, 2020 7:23 am
Reference the DataGrid or theData Array?
Hello,
I am working on an app that has a Map and a DataGrid. The map uses the LiveCode MapKit external, mergMK.
On the card with the mergMK mapkit (card “map”), when the user touches the callout, I want the correct image to open on another card (card “display”), where the user will see a larger image of the thumbnail image they just touched.
HERE is the code (on card “map”)
command mergMKAnnotationCalloutTapped pID, gHilitedLine, gImageIcon
get the dgData of group "DataGrid 1" of this stack
put the dgDataOfLine[pID] of group "DataGrid 1" of this stack into gImageIcon
set the cImageFilename of card "display" of this stack to gImageIcon["btn icon"]
lock screen for visual effect
go to card "display" of this stack
unlock screen with visual effect "push left very fast"
end mergMKAnnotationCalloutTapped
The above code will GO TO card “display” but no image appears.
My confusion about whether to reference the DataGrid or theData Array happens because on card “list”, which also contains the DataGrid, I have the following code:
command uiPopulatePeople
put specialFolderPath("desktop") & "/Images/" into theImageFolder
put “123 Main Street" into theDataA[1]["address"]
put “Old Glass Tower" into theDataA[1]["title"]
put theImageFolder & “Glass Tower small.jpg” into theDataA[1]["image URL"]
put the short id of image “Glass Tower large.jpg of card "resources" into theDataA[1]["btn icon"]
put “Photo Credit information" into theDataA[1]["credit"]
lock screen
set the dgData of group "DataGrid 1" to theDataA
set the dgHilitedLines of group "DataGrid 1" to 1
unlock screen
end uiPopulatePeople
I have approximately 10 images so it goes from theDataA[1] to theDataA[10]. I want the mergMKAnnotationCalloutTapped on card “map” to reference the line with….
“put the short id of image “Glass Tower large.jpg of card "resources" into theDataA[1]["btn icon”].”
However, for the DataGrid, I don’t use all of the array.
on FillInData pDataArray
set the text of field "address" of me to pDataArray["address"]
set the text of field "title" of me to pDataArray[“title”]
set the filename of image "image" of me to pDataArray["Image URL”]
--set the short id of btn "image" of me to pDataArray[“image”]**I would prefer to use a button on the Row Template instead of an image object.
end FillInData
So in the mergMKAnnotationCalloutTapped handler, I’m confused if I should be using the dgData (or dgText) since I don’t technically use the line of code that shows the larger image on the DataGrid.
ADDITIONALLY, as you can probably see from the code I included, I’m having to use a specialFolderPath to get the small images into an image object on the Row Template of the DataGrid. For all of the other images I’m using in the app, I was able to “import as control” and put them on the last card of my stack (card “resources”). Elsewhere in the stack I am using buttons to display the images, but I am not sure how to reference the images by using a button on the row template. From what I’ve been able to gather in the LiveCode Forums, I need to import the images onto the same stack as the row template, but I have not been successful in doing so.
Any suggestions or tips on my issues would be greatly appreciated!
Charlie
Hello,
I am working on an app that has a Map and a DataGrid. The map uses the LiveCode MapKit external, mergMK.
On the card with the mergMK mapkit (card “map”), when the user touches the callout, I want the correct image to open on another card (card “display”), where the user will see a larger image of the thumbnail image they just touched.
HERE is the code (on card “map”)
command mergMKAnnotationCalloutTapped pID, gHilitedLine, gImageIcon
get the dgData of group "DataGrid 1" of this stack
put the dgDataOfLine[pID] of group "DataGrid 1" of this stack into gImageIcon
set the cImageFilename of card "display" of this stack to gImageIcon["btn icon"]
lock screen for visual effect
go to card "display" of this stack
unlock screen with visual effect "push left very fast"
end mergMKAnnotationCalloutTapped
The above code will GO TO card “display” but no image appears.
My confusion about whether to reference the DataGrid or theData Array happens because on card “list”, which also contains the DataGrid, I have the following code:
command uiPopulatePeople
put specialFolderPath("desktop") & "/Images/" into theImageFolder
put “123 Main Street" into theDataA[1]["address"]
put “Old Glass Tower" into theDataA[1]["title"]
put theImageFolder & “Glass Tower small.jpg” into theDataA[1]["image URL"]
put the short id of image “Glass Tower large.jpg of card "resources" into theDataA[1]["btn icon"]
put “Photo Credit information" into theDataA[1]["credit"]
lock screen
set the dgData of group "DataGrid 1" to theDataA
set the dgHilitedLines of group "DataGrid 1" to 1
unlock screen
end uiPopulatePeople
I have approximately 10 images so it goes from theDataA[1] to theDataA[10]. I want the mergMKAnnotationCalloutTapped on card “map” to reference the line with….
“put the short id of image “Glass Tower large.jpg of card "resources" into theDataA[1]["btn icon”].”
However, for the DataGrid, I don’t use all of the array.
on FillInData pDataArray
set the text of field "address" of me to pDataArray["address"]
set the text of field "title" of me to pDataArray[“title”]
set the filename of image "image" of me to pDataArray["Image URL”]
--set the short id of btn "image" of me to pDataArray[“image”]**I would prefer to use a button on the Row Template instead of an image object.
end FillInData
So in the mergMKAnnotationCalloutTapped handler, I’m confused if I should be using the dgData (or dgText) since I don’t technically use the line of code that shows the larger image on the DataGrid.
ADDITIONALLY, as you can probably see from the code I included, I’m having to use a specialFolderPath to get the small images into an image object on the Row Template of the DataGrid. For all of the other images I’m using in the app, I was able to “import as control” and put them on the last card of my stack (card “resources”). Elsewhere in the stack I am using buttons to display the images, but I am not sure how to reference the images by using a button on the row template. From what I’ve been able to gather in the LiveCode Forums, I need to import the images onto the same stack as the row template, but I have not been successful in doing so.
Any suggestions or tips on my issues would be greatly appreciated!
Charlie