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

Announcement

Collapse

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

List Control - Enable / Disable a button

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

    List Control - Enable / Disable a button

    The onItemDraw event of the list control allows conditional logic on the client side.
    I can get row colors, text changes on buttons all very easily from the example syntax provided. I have a need to disable a button based on a value of a control in the list. My goal is to remove all the server side conditional logic and move to client side. If anyone has the magic syntax it would be greatly appreciated. Thanks in advance.

    Here the link where you can download the sample object.
    http://downloads.alphasoftware.com/V...transcript.htm

    if(data.State == 'CO' ) {
    var e = {listElement:btn1};
    //change the text of the button to the last name.
    e.innerHTML = data.Lastname;

    //alert(e);
    //document.getElementById("Btn1").disabled = true;
    //e.setElementDisabled('#Btn1',true);
    //document.getElementById("btn1").disabled = true;
    //e.setButtonDisabled('btn1',true);
    //var btn = {dialog.object}.getControl('BTN1');
    //btn.setDisabled(false);

    }

    //alternate the shade
    if( (index % 2) == 0 ) {
    ele.style.backgroundColor = '#fffaeb';
    } else {
    ele.style.backgroundColor = '#d4fad2';
    }

    //do something special button in row where state = MA
    if(data.State == 'MA') {
    e = {listElement:btn1}
    e.style.backgroundImage = 'none;';
    e.style.backgroundColor = 'yellow';
    }

    #2
    Re: List Control - Enable / Disable a button

    You have a pointer to "e"... and "disabled" is a property of "e". This disables the button if the State is "MA"...

    Code:
    if(data.State == 'MA') {
    	e = {listElement:btn1};
    	e.style.backgroundImage = 'none';
    	e.style.backgroundColor = 'yellow';
    	e.disabled = true;
    }
    Note that there is an error in the example's code.

    Code:
    //do something special button in row where state = MA
    if(data.State == 'MA') {
    e = {listElement:btn1};
    e.style.backgroundImage = 'none;';
    e.style.backgroundColor = 'yellow';
    }
    The e.style.backgroundImage = 'none;'; has a semi-colon immediately after none which causes a problem for any style settings.
    Last edited by Davidk; 12-17-2016, 02:35 PM.

    Comment


      #3
      Re: List Control - Enable / Disable a button

      I tried many things except the obvious. Thanks David. Appreciate the prompt reply. Have a great weekend.

      Comment


        #4
        Re: List Control - Enable / Disable a button

        Just one followup. When I use IOS7 style, the button respects the disable property, but when I change the class to iOS7ButtonDisabled, it returns a older gray button instead of iOS7 looking button.
        e.className = 'iOS7ButtonDisabled' (not good looking)
        I found if I used iOS7TabTButtonDisabled, this looked better. It still had blue border, but the text was disabled. I would like the border gray so I tried the following: e.style.border-color = '#c0c0c0'; and e.border-color = '#c0c0c0';
        Both of these options did not work. It there a way to modify the style properties.

        One more observation. The disabled button displays on the mobile device but it still allows me to click the button.

        Here is the element:
        <button a5-item="_systemButtononClick_B1TEST" id="LOGINMOBILE_MOBILEMENU_04726ARNE_SCHEDULECH_BJRG.LIST_SCHEDULE.B1TEST.BTN.0" class="iOS7ButtonDisabled" style="cursor: pointer; width: 87px; " title="" disabled="">disabled</button>
        Last edited by frankiez; 12-17-2016, 11:06 AM. Reason: more information

        Comment


          #5
          Re: List Control - Enable / Disable a button

          Interesting... I think this may be due to List controls events for Buttons, Hyperlinks, etc. now being handled by the a5-item attribute. I'm not sure of the best way to handle this, but this does work.

          You can see in the element you posted... that a5-item has a value of _systemButtonClick_B1TEST. So... let's remove that value when the List item is drawn...

          Code:
          if(data.State == 'MA') {
          	e = {listElement:btn1};
          	e.attributes['a5-item'].value = '';
          	e.className = "null iOS7Button iOS7ButtonDisabled";
          }
          Also note the className. You were applying only the disabled classname. But if you were to create a button outside the List control, and set it's enable property to 1=0, and then inspect that control, you'll see the classname setting as above. You must still style the button, but then add it's disabled style properties. I just check to see what Alpha is doing... and then copy it.

          Comment


            #6
            Re: List Control - Enable / Disable a button

            Your code is far more elegant than my solution to java script the click event to return under certain conditions to give the appearance of a disabled control.
            Your solution worked perfectly David. Thank you again. I am learning a lot from your posts.


            I posted my code and attached a screen shot so others can see the final results. I wanted the buttons to enable / disable based on status to reduce options a user can choose from. It works perfectly. Initially, I used server side conditional logic which had limitations. The client side is much more flexible.

            // get pointer to button element.
            var eIN = {listElement:BUTTON_SCHEDULE_CHECKIN};
            var eOUT = {listElement:BUTTON_SCHEDULE_CHECKOUT};
            var eSPN = {listElement:BUTTON_S_P_NS};

            if( data.CheckInOutStatus == 0 ) //pending
            {
            ele.style.backgroundColor = '#ffffff'; //white
            eOUT.disabled = true;
            eOUT.attributes['a5-item'].value = '';
            eOUT.className = "null iOS7Button iOS7ButtonDisabled";
            }

            if( data.CheckInOutStatus == 1 ) //checked in
            {
            ele.style.backgroundColor = '#ffe180'; //amber

            eIN.disabled = true;
            eIN.attributes['a5-item'].value = '';
            eIN.className = "null iOS7Button iOS7ButtonDisabled";

            eSPN.disabled = true;
            eSPN.attributes['a5-item'].value = '';
            eSPN.className = "null iOS7Button iOS7ButtonDisabled";
            }


            if( data.CheckInOutStatus == 2 || data.CheckInOutStatus == 3 || data.CheckInOutStatus == 4 || data.CheckInOutStatus == 100 )
            {

            if( data.CheckInOutStatus == 100 ) //checked out
            {
            ele.style.backgroundColor = '#d4fad2'; //green
            }
            else
            {
            ele.style.backgroundColor = '#facddc'; //reddish for sick,personal or off time
            }

            eIN.disabled = true;
            eIN.attributes['a5-item'].value = '';
            eIN.className = "null iOS7Button iOS7ButtonDisabled";

            eSPN.disabled = true;
            eSPN.attributes['a5-item'].value = '';
            eSPN.className = "null iOS7Button iOS7ButtonDisabled";

            eOUT.disabled = true;
            eOUT.attributes['a5-item'].value = '';
            eOUT.className = "null iOS7Button iOS7ButtonDisabled";

            }
            Attached Files

            Comment


              #7
              Re: List Control - Enable / Disable a button

              Glad it worked out. I don't think you need the .disabled = true; now.

              Comment

              Working...
              X