Announcement

Collapse
No announcement yet.

Conditional Image in a grid

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #2
    Re: Conditional Image in a grid

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

    Dhana

    Comment


    • #3
      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.

      Comment


      • #4
        Re: Conditional Image in a grid

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

        Thanks
        Dhana

        Comment


        • #5
          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__N M__accept.png'>";
          }
          else
          {
          {stato} = "<img src='/accept.png'>";
          }


          shows no image.

          Comment


          • #6
            Re: Conditional Image in a grid

            [quote author=marcov link=topic=1642.msg5853#msg5853 date=1283938044]
            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__N M__accept.png'>";
            }
            else
            {
            {stato} = "<img src='/accept.png'>";
            }


            shows no image.
            [/quote]

            The path need to be readable from the web.

            Insteado of:
            C:Programmi
            etmakev5wwwrootscriptcaseappFidelity\_libimggrp__N M__accept.png

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

            Comment


            • #7
              Re: Conditional Image in a grid

              Thanks now works correctly!

              Comment


              • #8
                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

                Comment


                • #9
                  Re: Conditional Image in a grid

                  ok thanks for your clarification!

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

                  Comment


                  • #10
                    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.

                    Comment


                    • #11
                      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__]

                      Comment

                      Working...
                      X