Can I dynamically show report parameters based on the selection on the other parameter?

(24 posts) (2 voices)

Tags:

No tags yet.

  1. jasmondluk, Member

    Say for example as below, can it only do such a way that it will only show in_option2 parameter to user only if in_option1 is selected 'Y'? Thanks.

    DROP PROCEDURE IF EXISTS sp_DBR_create_branch_center
    $$
    CREATE PROCEDURE `sp_DBR_create_branch_center`(in_option1 varchar(1), in_option2 varchar(255))
    BEGIN

    END
    $$

  2. jasmondluk, Member

    Any suggestion? Thanks.

  3. myDBR Team, Key Master

    You can add JavaScript code to track changes to the in_option1 and hide the in_option2 when needed. As an example, put following into Help/Javascript field:

    <script>
    $(document).on('change', '[name="u1"]', function() {
    $(this).closest('tbody').find('row2').toggle();
    });
    </script>

    --
    myDBR Team

  4. jasmondluk, Member

    Where can I locate the Help/Javascript? Thanks.

  5. myDBR Team, Key Master

    You can find in the "Report info" page. Click the edit-link for the in the main page.

    --
    myDBR Team

  6. jasmondluk, Member

    I can only see below in the main page. Where should I go?

    New report
    New folder
    SQL Editor
    Data browser
    Show access rights
    Settings:
    Report categories
    Organizations
    Users
    Groups
    Styles
    Parameter queries
    Templates
    Server side files
    Scheduled tasks
    Synchronization
    Shortcuts
    Notifications
    Environment settings
    Remote servers
    Replicas
    Licenses
    Failed Logins
    Query cache
    Demo / Localization
    About / Update
    Help

  7. myDBR Team, Key Master

    Click the 'edit'-link under the report you wish to add this behavior to.

    --
    myDB Team

  8. jasmondluk, Member

    Found it now. May I know what it mean for below? How does it related to my in_option1 and in_option2 and to hide option2 when option1 select 'Y"?
    1. [name=u2] and
    2. $(this).closest('tbody').find('row2').toggle();

    Thanks.

  9. myDBR Team, Key Master

    You can also use following code snippet:

    <script>
    $(document).on('change', '[name="u1"]', function() {
    if (this).val()=='Y')) {
    $(this).closest('tbody').find('.row2').show();
    else {
    $(this).closest('tbody').find('.row2').hide();
    }
    });
    </script>

    The code watchs the changes to the firsrt parameter (CSS selector '[name="u1"]'). If the value for it is Y, the second parameter (CSS selector '.row2') his shown, else hidden.

    Note that this is not myDBR functionality, but your own code.

    --
    myDBR Team

  10. jasmondluk, Member

    What we would to do is to show in_monthlyfee only if "Create separate entity" select "Y".

    We tried the code but in_monthlyfee doesn't show/hide accordingly. Please see the screen capture in below. Please advise if I have done anything wrong. Thanks.

    https://drive.google.com/file/d/1kZom11SQTVq1zVBwZ9nw6OacF6PuwhXx/view?usp=share_link
    https://drive.google.com/file/d/1kQvu7FPVa-n8bk_Px1W8UFygK89x4MdJ/view?usp=share_link
    https://drive.google.com/file/d/1kY6PlYv5S4PI-P08R5dv-4ool-S880pP/view?usp=share_link

  11. myDBR Team, Key Master

    The code looks ok. What does "accordingly " mean? It does not work at all or what?

    Use the JavaScript debugger to see what is going on. Add the debugger-statement to the script and open the browser's debugger. Then click the Yes/No button.

    --
    myDBR Team

  12. jasmondluk, Member

    It doesn't work. When I select "N" for "Create separate entity" in_monthlyfee field doesn't go away

  13. myDBR Team, Key Master

    What are the actual values in your Yes/No radio buttons?

    --
    myDBR Team

  14. jasmondluk, Member

    select 'Y', 'Yes'
    union
    select 'N', 'No'

    This is the parameter query

  15. myDBR Team, Key Master

    Use the JavaScript debugger to see why it is not working for you.

    --
    myDBR Team

  16. jasmondluk, Member

    I am able to make it work now. What if I also want to check the value of row2 and hide/show row4 accordingly when the parameter options appeared?

  17. myDBR Team, Key Master

    You can wrap the script into document ready and check the initial value for the field:

    $(document).ready(function() {
    // Document loaded, initial state
    $(document).on('change', '[name="u1"]', function() {
    // Action when data changed
    });
    });

    --
    myDBR Tea,

  18. jasmondluk, Member

    How do I get the value of row1 parameter when document is loaded?

  19. myDBR Team, Key Master

    You can use call:

    document.querySelector('input[name="u1"]:checked').value

    --
    myDBR Team

  20. jasmondluk, Member

    How to hide/show says, row2 in the initial state?

  21. myDBR Team, Key Master

    Excatly the same way you do it in the 'change' event.

    --
    myDBR Team

  22. jasmondluk, Member

    I tried $(this).closest('tbody').find('.row2').hide(); but it didn't work.

    I opened the debugger and do not see any error

  23. myDBR Team, Key Master

    You can use:

    $('[name="u2"]').closest('.row2').hide()

    to hide the row.

    --
    myDBR Team

  24. jasmondluk, Member

    Thanks


Reply

You must log in to post.