Hide more than one datatable with button

Hey!

i want to hide a datatable with a button dynamically, its hide on form load.

in the future i want to hide more than one datatable with one button.
so maybe we can do this with a Class?

Thx for your help!

Hi @TomRischkau,

You can totally do that with a class, but a simpler way is to add an extra line of code to the button's Click property:

Hey @IliaLazarevskii,

Ah thx! thats a good comment.
but i want that its dynamically change the status from hide to show.

Hi @TomRischkau,

I'm not sure if I'm following. Could you share more about your use case?
If you need to hide/show the controls whenever the button is pressed, I suggest something like this:

fd.control('DataTable1').hidden = !fd.control('DataTable1').hidden;
fd.control('DataTable2').hidden = !fd.control('DataTable2').hidden;

This code changes each control's hidden property to the opposite of its current value.

Hey @lliaLazarevskii,

I created a list where all my company's projects are listed and all project roles with all responsible employees are shown.

I have a lot lookup fields and dropdown fields.

We want to track all changes on these fields. My idea is to track these in a datatable next to the fields, hide the datatables and when an employee wants to review the changes, he clicks a button and the datatable is shown.

the code works perfect, thx!

Hi @IliaLazarevskii ,

how can i hide the control from the beginning?
when i use CSS the button doesnt work.

Hi @TomRischkau,

Add this to the JavaScript tab of the form:

fd.spRendered(() => {
    fd.control('DataTable1').hidden = true;
    fd.control('DataTable2').hidden = true;
});

This is how it should look: