Conditional Image in a grid

If you have ever needed to add a conditional image on a grid, you can use the following options:

Create a new text field and use an existing text field.

onRecord event:
if ({field_name} == 1) {
{field_name} = “<img src=’…/lock.png’ />”;
} else {
{field_name} = ‘’;
}

or a bit cleaner …

{field_name} = {field_name} == 1 ? “<img src=’…/lock.png’ />” : “”

This will display the image only when needed.

It is also possible to include the field text with the image by using {field_name} .= {field_name} . “<img src=’…/lock.png’ />”;

Regards,
Scott.

Re: Conditional Image in a grid

Scott,
Nice…! can it be used for Documents…too…then what is the tag to be used…?

Dhana

Re: Conditional Image in a grid

In taking a quick look:

Document: You could check the filename of the field, and based on the extension, display a different image. (or did I over simplify your question?)

Regards,
Scott.

Re: Conditional Image in a grid

Scott,
Ok.! let me trace the code …!

Thanks
Dhana

Re: Conditional Image in a grid

what is the correct syntax for Displayed the image in a field?
I tried this but does not work.
what is the correct path for images?

if (({stato} == 0) and ({richiesta} == 1))
{
{stato} = “<img src=‘C:Programmi
etmakev5wwwrootscriptcaseappFidelity_libimggrp__NM__accept.png’>”;
}
else
{
{stato} = “<img src=’/accept.png’>”;
}

shows no image.

Re: Conditional Image in a grid

The path need to be readable from the web.

Insteado of:
C:Programmi
etmakev5wwwrootscriptcaseappFidelity_libimggrp__NM__accept.png

Try
/scriptcase/app/Fidelity/_lib/img/grp__NM__accept.png

Re: Conditional Image in a grid

Thanks now works correctly!

Re: Conditional Image in a grid

You need to know that if you deploy on a differente server, /scriptcase/app/Fidelity/_lib/img/grp__NM__accept.png will no longer exists.

Try to you relative path like:

…/_lib/img/grp__NM__accept.png

Re: Conditional Image in a grid

ok thanks for your clarification!

I have another question, can associate with the image a tooltip?

Re: Conditional Image in a grid

Take a look at http://www.w3schools.com/tags/tag_IMG.asp and see all the attributes.

Search for Tips and Notes or alt and title.

Re: Conditional Image in a grid

  1. Upload image [image_name.ext]
  2. You must use the image before in the application for it be moving to [_lib/img] dir
  3. …/lib/img/grp__NM_[image_name.ext] (don’t forget prefix [grp__NM__]