How to put multiple images in the same row of a datagrid form

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

How to put multiple images in the same row of a datagrid form

Post by montymay » Sat Nov 04, 2017 9:28 am

I have studied the lesson on how to put different images in a datagrid form, but the lesson uses only one image.

Code: Select all

    put "Jane" into theDataA[x]["FirstName"]
    put "Blue" into theDataA[x]["LastName"]
    put "Secret Agent" into theDataA[x]["Title"]
    put theImageFolder & "monkey.jpg" into theDataA[x]["Image URL"]
However, I have a DG form into which I want to put three different images in the each row, and each row will not necessarily have the same combination of images. If it can done, I am guessing the answer has something to do with a modification of the last line, but I can't find any discussion in the forum? If it is possible, can you give me a pointer or a code snippet? Thanks so much.

Monty May

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to put multiple images in the same row of a datagrid form

Post by Klaus » Sat Nov 04, 2017 10:23 am

Hi Monty,

if you have three images, then you need to supply them to the datagrid:

Code: Select all

...
put "Jane" into theDataA[x]["FirstName"]
put "Blue" into theDataA[x]["LastName"]
put "Secret Agent" into theDataA[x]["Title"]
put theImageFolder & "monkey.jpg" into theDataA[x]["Image URL"]
put theImageFolder & "money.jpg" into theDataA[x]["Image URL2"]
put theImageFolder & "monk.jpg" into theDataA[x]["Image URL3"]
...
Then in the behaviour of the datagrid:

Code: Select all

on fillindata theDataArray
  ## Put your text into the appropriate fields
  ## ...
  set the filename of img "image1 in datagrid" to theDataArray["Image URL"]
  set the filename of img "image2 in datagrid" to theDataArray["Image URL2"]
  set the filename of img "image3 in datagrid" to theDataArray["Image URL2"]
end fillindata
I hope that is what you mean. 8)


Best

Klaus

montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Re: How to put multiple images in the same row of a datagrid form

Post by montymay » Sat Nov 04, 2017 7:30 pm

Hi Klaus

Thank you for your quick reply and the code. You understood what I meant and the code works perfectly. (Of course, the typo in the last line of the behavior script was obvious.) I've yet to understand "[Image URL]", but enlightenment will come in time. :D

Monty

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to put multiple images in the same row of a datagrid form

Post by Klaus » Sun Nov 05, 2017 2:29 am

Hi Monty,
montymay wrote:
Sat Nov 04, 2017 7:30 pm
I've yet to understand "[Image URL]", but enlightenment will come in time. :D
this is just a name for this key in the array.
Could also be like this, which makes it clearer:
...
put imgFol & "monkey.jpg" into theDataA[x]["keyname_holding_path_to_image_file_on_disk_1"]
put imgFol & "money.jpg" into theDataA[x]["keyname_holding_path_to_image_file_on_disk_2"]
...

Best

Klaus

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”