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

Android and Cross Browser TextBox Date Picker

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

    Android and Cross Browser TextBox Date Picker

    Date Pickers, for Text Controls, format and function a bit differently depending upon where they're used.

    On an Android device you don't want the soft keyboard popping up. In a desktop browser you may prefer to have Chrome, Firefox, and Edge behave similarly to each other.

    However, the Input Type "Date" is supported in Chrome, but not under Firefox or others.

    So... the trick is to use one Textbox Control which will function appropriately within the browser it's running in... and behave nicely under Android.

    To do this we must surrender the Alpha built-in Calendar Date Picker and use the jQuery Date Picker. There are lots of themes available and you can create your own if you like.

    Attached is an a5w page running a UX Component... which is the criteria established for this process.

    There are 4 TextBox Controls... each with slightly different settings. The settings are displayed for each TextBox.

    Date 1, 3, and 4 function slightly differently for each browser.

    Date 2 responds appropriately under Android... and responds exactly the same under Chrome, Firefox, Edge, and IE.

    There are only 2 areas to review within the UX:

    onRenderComplete : detects the browser and sets stuff up for Android and Date 2
    Javascript function : setDefaultDate() : this tests for each browser and sets default dates where needed. Different formats are required for different browsers.
    EDIT: Date 2 has it's property... Custom In-Control Buttons turned on. So have a look in that area for settings and code.

    The a5w page was modified slightly from it's default. The jQuery Theme was added.

    Testing 5 targets and 4 TextBox controls gets into a "Who's On First" scenario. So if anyone finds something odd... please post.
    Attached Files
    Last edited by Davidk; 06-09-2017, 10:53 AM.

    #2
    Re: Android and Cross Browser TextBox Date Picker

    All seems to work well David, tested on Chrome and android. But in Chrome the Date 2 field shows in american date format, although the calendar pops up in UK format.

    Comment


      #3
      Re: Android and Cross Browser TextBox Date Picker

      Lance... not sure what that means... what does that look like? I don't see anything odd about the jQuery calendar for Date 2. Although I'm in Canada, and like you... normally use the "correct" date format, I'm currently formatted for the US. You're in the UK, so what is your PC date setting? Also, note the EDIT I added to the original post.

      Comment


        #4
        Re: Android and Cross Browser TextBox Date Picker

        Hi David,

        My PC date settings are set to dd/MM/yyyy and here is a screen shot of what I get
        dates.png

        Comment


          #5
          Re: Android and Cross Browser TextBox Date Picker

          Ok... you wrote that the calendar was popping up a different format. I understand the TextBox US date format... that's how it was written. Have a look at the Javascript function "setDefaultDate"... change the format there. The setup of some TextBox controls for date demands the .setValue() format be "yyyy-MM-dd". But Date 2 is open so it'll take what you give it.

          On further thought, there's no reason the code can't pick up the UX Date Format. I've updated the original attached sample to do this.

          Comment


            #6
            Re: Android and Cross Browser TextBox Date Picker

            I can confirm changing the setDefaultDate format changed to the UK format. Thanks for this

            Comment


              #7
              Re: Android and Cross Browser TextBox Date Picker

              Looks great.

              Thanks David

              Comment


                #8
                Re: Android and Cross Browser TextBox Date Picker

                One more niggling issue for me.

                I can get this to work correctly when just setting up a UX for a new record, but editing previous records still doesn't quite work right.

                In my case, I am picking a record from a list and then using {dialog.Object}.populateControlsFromTable( {dialog.Object}.getValue('LIST1') );

                All the controls fill in fine except for the date controls with an html5 date format.

                I can't seem to figure out the correct settings to get them to display properly. They show up blank the same way they would if you used "=date()" in their initial value.

                Note: the value looks as if it's actually being set properly - because if I do an alert of the value of the control, the correct value shows up. It just doesn't display.

                Comment


                  #9
                  Re: Android and Cross Browser TextBox Date Picker

                  There's a lot going on here so you'd need to be a bit more specific about where it doesn't work. Is it Android?

                  Comment


                    #10
                    Re: Android and Cross Browser TextBox Date Picker

                    Sorry, yes on Android.

                    Comment


                      #11
                      Re: Android and Cross Browser TextBox Date Picker

                      To be even more clear:

                      Android, with html5 set to date with no date picker.

                      That works the best on strictly android devices.

                      As I said, I can get the field to set a default date just fine, but it won't show a date populated from a table now ...

                      Comment


                        #12
                        Re: Android and Cross Browser TextBox Date Picker

                        You need to follow the same process as in the original example. Android wants the date format as yyyy-MM-dd.

                        By using .populateControlsFromTable() you're populating your date control with a format of, for example, MM-dd-yyyy. Android doesn't understand and you get a console format warning... and a blank display in the control.

                        In the onRenderComplete event, after the browser has been established, save that value to a namespace variable. We'll use that in the List onSelect.

                        Code:
                        {dialog.Object}.__currBrowser = currBrowser;
                        Also, set up the Bound Date Control. In my case, my Bound Date Control is REPORTDATE. onRenderComplete in the example is already setting up DATE2... so just add another control...

                        Code:
                        if(currBrowser != 'Android'){
                        	//we are going to use jQuery datepicker for Date2 instead of the built-in calendar
                        	//have to escape the periods for jQuery... sheesh
                        	jQuery("#{dialog.ComponentName}\\.V\\.R1\\.DATE2").datepicker();
                        	jQuery("#{dialog.ComponentName}\\.V\\.R1\\.REPORTDATE").datepicker();
                        }else{
                        	$('{dialog.ComponentName}.V.R1.DATE2.CUSTOMBUTTONSTATIC.0').style.display="none";
                        	var dateEle = $('{dialog.ComponentName}.V.R1.DATE2');
                        	dateEle.setAttribute("type","date");
                        
                        	$('{dialog.ComponentName}.V.R1.REPORTDATE.CUSTOMBUTTONSTATIC.0').style.display="none";
                        	var dateEle = $('{dialog.ComponentName}.V.R1.REPORTDATE');
                        	dateEle.setAttribute("type","date");
                        }

                        In your List onSelect event... test for the browser, then populate... but for Android include an onCallbackCompleteCode Javascript function.

                        Code:
                        var currBrowser = {dialog.Object}.__currBrowser;
                        
                        switch(currBrowser){
                        	case 'Android':
                        		{dialog.Object}.populateControlsFromTable({dialog.Object}.getValue('LISTCUST'),false,'formatAndroidDate();');
                        		break;
                        	default:		
                        		{dialog.Object}.populateControlsFromTable({dialog.Object}.getValue('LISTCUST'));
                        }
                        The Javscript functions section will include...

                        Code:
                        function formatAndroidDate(){
                        	var objDate = new Date();
                        	var strDate = {dialog.Object}.getValue('ReportDate');
                        	objDate.fromFormat(strDate,'MM/dd/yyyy');
                        	var dfltDate = objDate.toFormat('yyyy-MM-dd');
                        	{dialog.Object}.setValue('ReportDate',dfltDate);
                        }
                        Here we get the date, a string, assign it to a date object, then send it back out again properly formatted for Android.

                        Comment

                        Working...
                        X