Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook



The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic

Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.

If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.

Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.

Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Conditional Syle based on whether Image exists

  • Filter
  • Time
  • Show
Clear All
new posts

    Conditional Syle based on whether Image exists


    I'm trying to turn the text colour of a button red when there is no image in an image control and then black when there is an image. Nothing I'm doing works, any pointers most welcomed....


    Re: Conditional Syle based on whether Image exists

    Grid? UX? List control? Version of Alpha software?
    NWCOPRO: Nuisance Wildlife Control Software My Application: "Without forgetting, we would have no memory at what was I saying?"


      Re: Conditional Syle based on whether Image exists

      Since I am the worst at writing code I always come up with alternatives. Create TWO buttons one with each color put them in their own containers and use a show hide condition for the containers (client-side) based on the image control field being <>''
      NWCOPRO: Nuisance Wildlife Control Software My Application: "Without forgetting, we would have no memory at what was I saying?"


        Re: Conditional Syle based on whether Image exists

        V12 fully up to date. List control, detail view in a UX. Tried your suggestion and that works! Now, don't get me wrong, that's an admirable work around but surely there's got to be a better way... my conditional style is based on the same condition but it doesn't work or rather it seems to work sometimes that I haven't quite got my head round yet....


          Re: Conditional Syle based on whether Image exists

          Yes, you can modify the css based on anything - which is what you really want to do. Search the forum for conditional CSS - once you get the pointer to the element you should be able to figure it out from examples you can find here. Pretty sure it would be a javascript function, in an event on load or on change or both, but since I never really took the time to find it, figure out something, and actually implement it - I just did what I knew would work and get the result I want. The downside is now I have extra controls, which could at one point slow down my application or at the very least slow down load times.
          Your right there is a better way...
          NWCOPRO: Nuisance Wildlife Control Software My Application: "Without forgetting, we would have no memory at what was I saying?"


            Re: Conditional Syle based on whether Image exists

            Did you try the advanced-style option so you can edit the CSS based on the condition? That really should work for you. If you are getting unexpected results study the conditions and what is actually in the control - carefully.
            NWCOPRO: Nuisance Wildlife Control Software My Application: "Without forgetting, we would have no memory at what was I saying?"


              Re: Conditional Syle based on whether Image exists

              There are a few ways to work with images and List Controls with a Detail View. If your image is coming from your table and your List field is coming through as (B) and you have the Field Image Properties "Embed images into HTML" turned on... then your images will be base64 encoded and an empty image will render as...

              So, a conditional style on a button for an empty image might be...

              IMAGE = "data:image/png;base64,"
              With another conditional style for an image being...

              IMAGE <> "data:image/png;base64,"
              However, if you don't embed the image... then an empty binary image will render as...

              This doesn't even touch S3 images.

              So... how is your UX/Detail View/Image stuff put together. Knowing this will help.
              Last edited by Davidk; 01-21-2017, 12:56 PM.


                Re: Conditional Syle based on whether Image exists

                Thank you for that and all sounds very sensible. Its out of SQL database as a (B) field and its embedded into HTML.

                However further investigation has revealed that a major part of my problem is the dialog object which is the image control doesn't seem to exist UNTIL there is an image in it; so any attempt to reference it via the conditional style or JavaScript results in an error. Indeed when there is no image in it there is nothing visible on screen where the control should be

                I thought the key to this might be "no image found image" in the properties of the field in the list object but no matter what I set that to; it makes no difference to the behaviour when "empty" - maybe this is the key to the problem but no matter what I try I can't make this bit work either.


                  Re: Conditional Syle based on whether Image exists

                  Where is your button? In the List Control... or in the UX? And... where is the Image you're testing... in the List Control... or in the Detail View?

                  As well, it actually gets a bit more complex... because you could have a blob with no data which gets rendered as "data:image/png;base64," and also a true no image... which could be rendered like... "data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP4//8/AwAI/AL+eMSysAAAAABJRU5ErkJggg==".

                  And this is against an Image control in the Detail View of a List Control.

                  What I usually do is base conditions on the length of the image... but again it kinda depends "where" you're doing this. In a button on a UX...

                  Conditional Expression for no image... len(IMAGE)<200
                  Conditional Expression for an image... len(IMAGE)>200

                  Any image is going to be much larger than 200 characters.
                  Last edited by Davidk; 01-21-2017, 01:40 PM.


                    Re: Conditional Syle based on whether Image exists

                    Why not create a default value or image definition like for a new record using another condition? Make the condition IMAGE <>'' then assign an image to that. so that if it is blank you know what it will be.
                    NWCOPRO: Nuisance Wildlife Control Software My Application: "Without forgetting, we would have no memory at what was I saying?"


                      Re: Conditional Syle based on whether Image exists

                      Thanks for the help; I'm now developing a library of ways to do it which I will comment on if I ever get this to work fully but I've now hit a further hurdle. I'm using the Action Javascript of "Image Capture for List-Detail View". I've set it to PhoneGap preferred and am testing it using Working Preview etc but not the device so I'm just selecting images using the browser. This all works find and the image I select is shown on the screen


                      If you examine the image control no code seems to show it as having changed after having executed the above and in fact if I use {dialog.object}.getValue and "alert" the data it hasn't changed yet what's on screen obviously has. So the data in the control isn't changing yet the image displayed on screen is.
                      If you save the data still nothing changes but if you go out of the screen and back in again; then its changed and all of the tests based on the above and of my own devising work. I've tried to find a "refresh" to do some form of update to the image control but no joy so far.

                      Any thoughts?


                        Re: Conditional Syle based on whether Image exists

                        Working with Images and Dates is a world unto itself.

                        Your post is now jumping around a bit and that usually resolves into a bit of confusion.

                        When an image from a List is first displayed in it's Detail View, because you've selected to "Embed" the image... it's a base64 value.

                        Now... if you then perform your Image Capture, you've seen that the image changes... but the .getValue does not. Things are in transition at this point. Alpha knows what's going on behind the scenes.

                        However, the .src of that image has changed. So... depending on what you want to do... and where... and when... you need to check the .src.

                        So... instead of a .getValue()... get the image source doing this...

                        var ele = {dialog.Object}.getPointer('IMAGE');
                        Also, after your Image Capture... if you were to click back into the List row where you came from... and then did a .getValue() on the Image control, you'd see that it has changed... because going back to the List, stuff gets synced at bit on the client side.


                          Re: Conditional Syle based on whether Image exists

                          With HUGE thanks to Davidk and the others that replied; finally putting it all together I have made it work. The following JavaScript function (and please excuse my rusty code) correctly identifies "live" whether there is an image present so can be used in "conditional style" and, in my case, changes the button colour when you "take" a picture

                          function isImagePresent(controlName) {
                          var retVal
                          try {
                          	var ele = {dialog.Object}.getPointer(controlName);
                          	retVal = ele.src.length > 200;
                          } catch (e) {
                          	retVal = false;
                          return retVal;
                          so my conditional style contains two inverse statements along the lines of
                          isImagePresent('control_name') = false
                          to set the colour of the button

                          I can't help but feel the powers that be should make that a tad easier!!!!!


                            Re: Conditional Syle based on whether Image exists

                            Nice use of try/catch