Hide a Grid based on previous questions

Hi,

I would like to hide a grid based on a previous question the user will answer.

I have used this code to hide a tab but I would also like to hide one of the review grids.

//Hides Leave-A-Post Tab in Termination Details Wizard//
fd.spRendered(function() {

function enableOrDisableResolvedTab() {
    if (fd.field('Is_x0020_the_x0020_employee_x0020').value == 'Yes') {
        //disable Leave-A-Post tab
        fd.container('Tab0').tabs[1].disabled = true;
    } else {
        //enable the Leave-A-Post tab
        fd.container('Tab0').tabs[1].disabled = false;
    }
}

//call enableOrDisableResolvedTab when a user changes the status
fd.field('Is_x0020_the_x0020_employee_x0020').$on('change',enableOrDisableResolvedTab);

//call enableOrDisableResolvedTab on form load
enableOrDisableResolvedTab();

});

This review field is in a grid:

Dear @Qman,
Give your grid a class, for example: my-grid
image

Then use it in JavaScript to hide/show grid:

$('.my-grid').hide();
$('.my-grid').show();

Hi @Nikita_Kurguzov,

Thanks for replying.

That's simple enough.

How do I add a AND statement to this code:

fd.container('Tab0').tabs[1].disabled = true;

I'm not sure where to put this in.

Dear @Qman,
What AND statement are you talking about? If you want both to run, just use them one after the other, the order doesn't matter:

fd.container('Tab0').tabs[1].disabled = true;
$('.my-grid').hide();
1 Like

That simple? I've been spending several hours trying to fix this. Thank you so much!

Is jQuery used for writing code? If so, can you direct me to a good source to learn this and implement the language for my forms. I'm not very good at coding.

Dear @Qman,
Yes, jQuery is available on Forms. Usually, you can just google solution for any issue that you might have. For jQuery, you can check out this section here - jQuery Tutorial

All right, awesome!

Thank you.:slight_smile: You guys are awesome!

Hi Nikita!

I needed your help with a simple problem.

I have a couple of grids on the form which contain fields inside and I want to simply show those grids One Click at a time.

I currently have two grids hidden on load using this code (Placed in JS Editor):
$('.Wiz3MO2').hide();
$('.Wiz3MO3').hide();

I have a button on the form which I want to add an if statement.

The logic is:

If I click the button I want it to show Wiz3MO2.
If I click the SAME button again, I want it to show the next hidden grid (Wiz3MO3)

Right now, all it does is if I click that button, it will show all the hidden grids in one click but I want it to show one at a time.

I hope that makes sense!

Cheers!

Dear @DryChips,
You can check if a grid is hidden or not like this, and only enable one at a time:

if($('.Wiz3MO2').attr('style') == 'display: none;'){
  $('.Wiz3MO2').show();
}
else if($('.Wiz3MO3').attr('style') == 'display: none;'){
  $('.Wiz3MO3').show();
}
1 Like

Many many thanks Nikita! :smile: