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

Show/Hide if opened from a parent UX

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

  • Show/Hide if opened from a parent UX

    I have a parent UX, running in a tabbed UI.

    I have another UX called Customer

    I want to open the Customer UX in a pane of the tabbed UI, with controls to navigate through the records.

    I also want to open the Customer UX from a button on the parent UX, to view the specific Customer record that is being displayed in the parent UX. In this case, I want to hide all navigation controls.

    In the Customer UX, Javascript Functions, I put this:

    function isShown(){
    var pObj = {dialog.Object}.getParentObject()
    if(pObj) {
    return false;
    } else {
    return true;
    }
    }

    In the individual controls’ Client-ide Show/hide expression I have: isShown() = true

    The result is that the controls will hide correctly when opened from the parent UX...... until the Customer UX is opened in the pane of the tabbed UI. Once that happens, the controls will no longer be hidden when opened from the parent.

    I must be missing something. It seems that isShown() will fire the first time the Customer UX is opened by either method. After that the tabbed UI page must be reloaded in order for it to fire.

    Any help is appreciated.
    Last edited by Pizzadude; 07-10-2014, 03:12 PM.

  • #2
    Re: Show/Hide if opened from a parent UX

    I'm still looking for a solution.

    Here is a entertaining video that explains it better.... http://screencast.com/t/mGXvbjbTi

    Comment


    • #3
      Re: Show/Hide if opened from a parent UX

      Hi Joe,

      This is a bit tough because there are so many pieces involved. Put together a test tabbed ui and dialog. You don't need to include data binding... just some of the controls that are hidden/shown and some of the controls that are always shown. Include your isShown() function.

      Having the sample will really help walking through what might be going on.

      Maybe there is a caching thing happening.

      E.g. In your video you open the UX in a Tab... and you keep that tab around when you pop up the UX from the parent. What happens if you open the UX in a Tab, close the tab, then open the UX from the parent?

      Comment


      • #4
        Re: Show/Hide if opened from a parent UX

        Below are some sample files, as simplified as possible.

        It shows consistent behavior: The first time opened in a pane, it executes correctly. The first time opened as a child, it executes correctly. But once it has been opened by both methods, it retains the state of the most recent method. I hope that makes sense.
        Attached Files

        Comment


        • #5
          Re: Show/Hide if opened from a parent UX

          The calls to open CustomerTest certainly are bumping into each other.

          There is actually a Javascript error produced if you

          Open the CustomerTest UX via the Tabbed UI button
          Open the CustomerTest UX via the Link... and then close it
          Close the Tab which contains the CustomerTest UX
          Open the CustomerTest UX via the Link... a javascript error occurs.

          I would report this one. It's a good one.

          Here's a temp solution.

          Open your CustomerTest UX in design mode.
          Click on Save Page in the toolbar
          This will create an A5W Page with your CustomerTest UX embedded
          In your Tabbed UI, instead of having a button which opens the CustomerTest UX Component... add a button which opens an A5W Page... your CustomerTest A5W page.

          Now they won't bump into each other.

          Comment


          • #6
            Re: Show/Hide if opened from a parent UX

            I submitted a bug report.

            Nice trick launching the page, instead of the UX, in the pane. I would never have thought of that. Pure genius!

            Thanks!

            Comment


            • #7
              Re: Show/Hide if opened from a parent UX

              The solution, from Selwyn, on a Sunday.


              http://screencast.com/t/5qiGNxyN

              Comment


              • #8
                Re: Show/Hide if opened from a parent UX

                Very cool... and really excellent example of using the {dialog.Object} namespace.

                Comment


                • #9
                  Re: Show/Hide if opened from a parent UX

                  Prefixing the Javascript function name with {dialog.componentName}, as I have seen elsewhere, or this other neat trick of placing the js inside of the {dialog.object} variable/object is indeed way cool when using it in client-side show/hide expressions. But how can I do the same type of trick for client-side conditional styles that call JavaScript functions? The designer always complains about the syntax and I haven't found a way to make it generate the correct code.

                  Comment


                  • #10
                    Re: Show/Hide if opened from a parent UX

                    Rich, I have been wondering about that myself. For instance, I have controls where I want to conditionally change the label based on the same function Selwyn provided:

                    {dialog.object}.isShown = function(){
                    var pOcust = {dialog.Object}.getParentObject()
                    if(pOcust) {
                    return false;
                    } else {
                    return true;
                    }
                    }

                    In the control's label I have <div id="label"></div>

                    How can I conditionally set the div? I have not really spent any time on this yet, but it's on my list.

                    Comment


                    • #11
                      Re: Show/Hide if opened from a parent UX

                      This other thread, http://msgboard.alphasoftware.com/al...el-of-a-texbox, has been discussing setting labels dynamically. There are so many ways it can be done. Here's some techniques I have used:
                      1) In a Grid I have set column heading/labels in the server-side onInitializeEvent by stepping through the column labels and assigning new labels. The whole procedure is rather lengthy, but the critical part is this simple loop that looks for a particular column and changes it. I use a loop so that if I add more columns I do not have to recalculate a hard-coded value for the column index number:
                      Code:
                      [FONT=Fixedsys]
                        while .t.
                          if fieldName = upper(tmpl.field_info[ndx].Fieldname) then
                              ' Assign dynamic column label
                      	tmpl.field_info[ndx].column.heading = fieldLabel
                      	startNdx = ndx + 1
                      	exit while
                          end if
                          ndx = ndx + 1
                          if ndx > tmpl.fields then
                             ndx = 1
                          end if
                          if ndx = startNdx then
                             exit while
                          end if
                      end while
                      
                      [I]'--IMPORTANT:  In Grid's Properties / Advanced Properties, include following to force component to recalculate all HTML at render time:    
                         tmpl.flagMustRecalculateAllProperties = .t.[/I]
                      [/FONT]
                      This particular editable grid is so slow to open! Some day I will have to figure out faster ways of doing everything it does. Column labels, number of columns, type of controls that appear in the columns, which controls are modifiable based on user's access rights - they are all configured by the system administrator.

                      2) Sometimes I might include extra tables/views in the SQL for the Grid to retrieve configuration information about how the system administrator wants a particular data item labeled. In which case I put two controls on the form: 1) one control is to display the name of the field, as chosen by the system administrator, which comes from a lookup configuration lookup table, and 2) the actual data field that comes from the table being updated.

                      3) Another method is to put code into the client-side events like 'onGridRenderComplete', 'onSynchronizeDialog', and 'onRenderComplete' that sets the inner html of a span element or calls a grid or dialog method to set the value of a control. Here's an example of how I set an element in the free form edit region of a grid from the client-side 'onRenderComplete":
                      Code:
                      // Set title
                      var tx = {grid.Object}.argumentValue('pTemplate_Title');
                      if( tx == '' ) {
                      	tx = '(Not specified)';
                      }
                      $('SPAN_TEMPLATE_NM').innerHTML = tx;
                      4) There's other ways, too.

                      Comment


                      • #12
                        Re: Show/Hide if opened from a parent UX

                        Here is a caution for new JavaScript programmers, like me, that came from working in classical compiled languages:

                        You will get unexpected behavior with your "local variables" if you use the technique shown in posts #7 and #10. The variables defined in these functions do not behave like variables that are defined in global functions.

                        You will find that using "var" to declare a variable in these types of functions does not protect or hide that variable from the other attached functions. The other functions can access it and change it; they do NOT get their own instance of the variable like they would if they were global functions!

                        For example, put the following in a Grid's client side 'onObjectInitialize' event:
                        Code:
                        {Grid.object}.InitTest1 = function () {
                           var t1 = 'InitTest1';
                           alert('InitTest1: ' + t1);
                        }
                        
                        {Grid.object}.Test1 = function () {
                           alert('In Test1: ' + t1);
                        }
                        
                        {Grid.object}.Test2 = function() {
                        	alert('Test2 before: ' + t1);
                        	var t1 = 'Set by Test2';   
                        	alert('Test2 after: ' + t1);
                        }
                        Set up three toolbar action buttons to call the above code using text-mode inline javascript. Here's the code for the first button:
                        Code:
                        {Grid.object}.Test1();
                        Run the code in the browser with the browser's debugger turned on and click on the buttons in sequence to see that there is only one instance of the 't1' variable.

                        If you suppose that the 't1' variable was simply moved up a level to the grid.object then try adding a fourth button with the following inline JavaScript:

                        Code:
                        alert({Grid.object}.t1);
                        The 't1' variable is undefined for the above code, even after successfully running the other functions that declared and used the t1 variable!

                        Google terms like "JavaScript Variable Function Scope" and "Javascript closure" for more info.

                        Comment


                        • #13
                          Re: Show/Hide if opened from a parent UX

                          Hey Rich,

                          An interesting discussion.

                          I think I'm following what you're saying... but... I would never expect {grid.object}.t1 to be valid in this scenario. t1 never gets created in the {grid.object} namespace.

                          t1 get assigned as a variable within the function assigned to {grid.object}.Test

                          Comment


                          • #14
                            Re: Show/Hide if opened from a parent UX

                            Originally posted by Davidk View Post
                            Hey Rich,
                            ... t1 get assigned as a variable within the function assigned to {grid.object}.Test
                            I think you meant to say the t1 variable gets assigned a value in the two functions 'InitTest1()' and 'Test2()' . The interesting part is that in the context I described the three functions all use the same 't1' variable / property. Its value hangs around from function call to function call. In the Test2() function I show its value that it got from the InitTest1() function and then I change it. The Test1() function also shows that the variable just sticks around and maintains the last value set by either InitTest1() or Test2() function. "Function Scoping instead of Block Scoping" - it's strange stuff for me to get used to. There is a Block Scoping concept in the works for JavaScript 1.7 called the "let" statement: https://developer.mozilla.org/en-US/...JavaScript/1.7

                            Comment

                            Working...
                            X