Constraining a UX with Panels to an Element

Description

When a UX component that uses Panels is rendered, by default it consumes the entire window (this is only true if UX uses Panels).

images/uxpex.png
A UX with Panel Cards inside a div tag.

That means that if you have created an .a5w page to render the component and placed HTML markup on the page that you would like to be rendered in addition to the UX component, that markup will be overwritten by the UX. An advanced property of the UX now allows you to specify that the UX should be constrained to an element, rather than the entire window.

To see how an .a5w page can be defined with a DIV to contain the UX and how the UX can be configured so that it is constrained to this DIV element. (Requires build 4411 or above) follow the guide below or watch this video. You can also download the component.

Adding a UX Component with Panels to a DIV in an .a5w Page.

  1. In the UX Builder create a UX Component that uses Panels and Panel Cards. This guide uses the component created on the the Storing and Restoring Panels page.

    images/uxp.png
  2. If using the Storing and Restoring Panels example, open the UX Controls page for the component and uncheck the 'Mobile' checkbox from the Controls page toolbar.

    images/uxp2.png
  3. Open the UX Properties page. Scroll down the properties list to the Advanced section. Find the 'Render position type for UX component with Panels' and select the 'element' option from the dropdown.

    images/uxp3.png
  4. Set the 'Render target element' to be 'mydiv' or something similar. This will id the div where the component will live.

    images/uxp4.png
  5. Save the Component.

    images/uxp5.png
  6. Open the Web Projects Control Panel.

    images/uxp6.png
  7. From the 'Create a new' dropdown in the Web Projects Control Panel toolbar select 'A5W page'.

    images/uxp7.png
  8. Save the A5W page

    images/uxp8.png
  9. Open the A5W page's 'Source' pane.

    images/uxpsource.png
  10. Click on the 'Insert Component' button.

    images/uxp9.png
  11. Click the 'Select' button.

    images/uxp10.png
  12. Choose the UX Panels component that you want to place in a div and Click OK.

    images/uxp11.png
  13. Click OK

    images/uxp12.png
  14. Click the Copy Code to Clipboard button for the HEAD Section. Keep the "Xbasic/HTML to Insert a Component" dialog open.

    images/uxp13.png
  15. Use 'Paste' to add the code inside the a5w page's <head></head> tags.

    images/uxp14.png
  16. Add the following <div></div> tags to the <body></body> section of the A5W page.

    <div style="border: solid 3px blue; display:inline-block; padding: 20px;">
         <div id="mydiv" style="height: 6in; width: 4in;"
    
    
         </div>
    </div>
    images/uxp15.png
  17. Click the Copy Code to Clipboard button in the BODY Section.

    images/uxp16.png
  18. Click 'Paste' to add the 'Body Section' of the UX Component inside the second pair of div tags, like this:

    <div style="border: solid 3px blue; display:inline-block; padding: 20px;">
         <div id="mydiv" style="height: 6in; width: 4in;"
         <%a5 ?x_SAVE_RESTORE.Output.Body.Dialog2_HTML %>
         <%a5 ?a5dialogHelper_generateCORSHeaders() %>
         </div>
    </div>
    images/uxp17.png
  19. Optionally click the 'Copy Code to Clipboard' in the BODY TAG section of the Xbasic/HTML to Insert dialog.

    images/uxp18.png
  20. Paste the code inside the <body></body> tags on the A5W page.

    images/uxp19.png
  21. Click the 'Run' button in the A5W toolbar.

    images/uxp20.png
  22. Test the functionality of the component.

    images/uxp21.png
    A 'Save_Restore' UX component in a dix