[BEGINNER] Show image in datagrid?

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
shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

[BEGINNER] Show image in datagrid?

Post by shawnblc » Wed May 22, 2013 11:15 pm

In my database I'm storing the actual link for an image. Is there a way to show that image in a datagrid?

Example: in my database I have the actual image link

Code: Select all

http://forums.runrev.com/styles/prosilver/imageset/site_logo.gif

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: [BEGINNER] Show image in datagrid?

Post by Klaus » Thu May 23, 2013 12:40 pm

Hi Shawn,

yes, sure :-)

1. The datagrid needs to be of type FORM
2. Create an image object in the "row template" of your datagrid
3. Add this to the "FillInData" handler of the behavior script of your datagrid:

Code: Select all

on fillinData tData
  ## tData is an array!
  set the filename of image "the one with the remote image" of me to tData["db_field_with_image_url"]
  ## more datagrid stuff here...
end fillInData
Hint: This may cause in loooooong "loading" times of the datagrid if you have a lot of records in your data!


Best

Klaus

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

Re: [BEGINNER] Show image in datagrid?

Post by shawnblc » Sun May 26, 2013 2:13 am

When I try the following code my image isn't showing up in the datagrid.

Code: Select all

on fillinData tData
     -- tData is an array!
     set the filename of image "url to my image" of me to tData ["fldRegistered"]
     -- more datagrid stuff here...
   
end fillInData

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: [BEGINNER] Show image in datagrid?

Post by Simon » Sun May 26, 2013 3:01 am

Code: Select all

tData ["fldRegistered"]
Something is wrong there.
Should it be tData & field "fldRegistered"?
I'm not sure what they contain so not clear what should be happening.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: [BEGINNER] Show image in datagrid?

Post by Klaus » Sun May 26, 2013 12:49 pm

Hi Shawn,

how do you put the data into your datagrid?
Is your data an array?
Are you using a datatgrid of type FORM?

And is "fldRegistered" really the name of the key of the array that holds the image url?


Best

Klaus

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: [BEGINNER] Show image in datagrid?

Post by sturgis » Sun May 26, 2013 1:55 pm

Did you change the variable name of the fillindata from pDataArray (which is the default param name I believe) to tData? Or did you write your own fillindata and use tData? If the second, is the original fillindata still there? So that maybe there is a conflict?

Also, I see you have this:

Code: Select all

     set the filename of image "url to my image" of me to tData ["fldRegistered"]
Did you really name the image object in your template to "url to my image" ?
I find it easier to code these things if my names match my data keys.

You might rename the image object to to fldRegistered so that your line becomes

Code: Select all

     set the filename of image "fldRegistered" of me to pDataArray["fldRegistered"] 

Finally, when you added the image object, are you sure you added it to the correct spot? I'm sure you did, but just in case...

TO make sure, select your datagrid, click "row template", make sure you do NOT have "select grouped" chosen in the lc menubar. Then click your image object. If you can select only your image object when you do this it means the image object is OUTSIDE the group that it needs to be in. If you cannot select the image object but can see it chances are things are correct. TO confirm click the group (any object should work to select the group) and click the "edit group" button. At this point you should still be able to see the background, any fiends and objects that are in the template, and make changes.

If any of your objects disappear when you go into edit mode, that means they were outside the group and in the wrong place. The proper procedure to add objects to the template is.. click the "row template" button in the inspector, then select the group (with "select grouped" turned off of course) , then click "edit group" At this point, add, change, remove any objects in the group as needed, then reverse the order. Turn off edit group and close the edit group window, you'll be prompted to save.

Post Reply