Hiding inputs in dbr.report popup

(6 posts) (2 voices)

Tags:

No tags yet.

  1. macdonaldmik, Member

    Hello,

    I have a dbr.button that triggers a popup report for users to enter values. However, some of the lower inputs should be either invisible or rendered so a user can not input values in them because they are dependent on another input in the report.

    For example with this report:

    SELECT 'dbr.button', 'New Record';
    SELECT 'dbr.report', 'sp_create_Records', 'vName[]', 'event=click';
    SELECT 'Create Record';

    CREATE DEFINER=`mydbr`@`localhost` PROCEDURE `mydbr`.`sp_create_Records`(
    vOrganizationId int(11),
    vProviderLocationId int(11),
    vProviderId int(11),
    vClientId int(11),
    vRecordTypeId int(11),
    vAssessmentDate date,
    vAutoQualifier tinyint(1),
    vPreAssessmentSILevel int(1),
    vPrelimSILevel int(1),
    vFinalSILevel int(1),
    vLevelOfCare int(11),
    vSiLevel int(1),
    vReviewNumber int(1),
    vAverageDLA20 dec(3,2),
    vMGAF dec(3,1),
    vSIModifier int(1)
    )
    BEGIN

    INSERT INTO bham.Records(
    OrganizationId,
    ClientId,
    ProviderId,
    ProviderLocationId,
    RecordTypeId,
    AssessmentDate,
    AutoQualifier,
    PreAssessmentSILevel,
    PrelimSILevel,
    FinalSILevel,
    LevelOfCare,
    SiLevel,
    ReviewNumber,
    AverageDLA20,
    MGAF,
    SIModifier
    )

    If RecordTypeId = 4, I want to hide the input for SIModifier, MGAF, AverageDLA20.

    I'm new to myDBR and inherited this project so I apologize if I haven't provided enough detail. Happy to provide more info if needed.

    Thanks

  2. myDBR Team, Key Master

    Hi,
    The user enters the `vRecordTypeId` (either directly or from select list/radio button) and based on the value, you want to hide the last three columns?

    You can use JavaScript in the sp_create_Records's parameter screen to check if the value of the vRecordTypeId-field is 4 and then hide the fields in question. In the actual linked report you can then use your own logic to fill those values. Do remember to set the fields optional so that empty values can be passed when hidden.

    Btw, no use to use syntax `int(11)`/`int(1)`. You can use plain `int`. They are all the same int's. The int(11)-format is just an MySQL command line "feature" which can be used to format numbers in mysql-command line tool. It has nothing to do with the actual datatype. Same goes with `tinyint(1)`, just use `tinyint`. The decimal datatype however does need the precision and the scale definitions (decimal(3,2) can hold values between -9,99 to 9,99).

    --
    myDBR Team

  3. macdonaldmik, Member

    Thanks so much for this response. Is there any way for you to provide a small example of the js code I could insert in the sp_create_Records parameter screen?

  4. myDBR Team, Key Master

    What is the UI element type you are using for the vRecordTypeId (input field/list/radio button)?

    --
    myDBR Team

  5. macdonaldmik, Member

    It's a select list.

  6. myDBR Team, Key Master

    1. Add classes to the vRecordTypeId (="record-type") and to the optional fields (="record-type-optional")
    2. Make the optional fields optional (=empty values are accepted)
    3. Add following code to the sp_create_Records's Help/JavaScript field

    <script>
    $(document).ready(function() {
    function checkRecordType() {
    if ($('.record-type select').val()=='4')
    $('.record-type-optional').hide();
    else
    $('.record-type-optional').show();
    }
    checkRecordType();
    $( document ).on('change', '.record-type select', checkRecordType );
    });
    </script>

    --
    myDBR Team


Reply

You must log in to post.