Page 1 of 1

[BEGINNER] Show image in datagrid?

Posted: Wed May 22, 2013 11:15 pm
by shawnblc
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

Re: [BEGINNER] Show image in datagrid?

Posted: Thu May 23, 2013 12:40 pm
by Klaus
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

Re: [BEGINNER] Show image in datagrid?

Posted: Sun May 26, 2013 2:13 am
by shawnblc
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

Re: [BEGINNER] Show image in datagrid?

Posted: Sun May 26, 2013 3:01 am
by Simon

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

Re: [BEGINNER] Show image in datagrid?

Posted: Sun May 26, 2013 12:49 pm
by Klaus
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

Re: [BEGINNER] Show image in datagrid?

Posted: Sun May 26, 2013 1:55 pm
by sturgis
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.