Hide/Show tabs with condition (radio button or drop-down)

This sub-forum is for discussing all topics related to AppGini Helper JavaScript Library, provided by bizzworxx as a third-party AppGini plugin.
Post Reply
balfons
Veteran Member
Posts: 47
Joined: 2018-10-22 15:27

Hide/Show tabs with condition (radio button or drop-down)

Post by balfons » 2021-01-11 15:04

Hi!

I'm trying to hide/show (or fade in/fade out) some custom tabs according to the value of a field wich is radio button/drop-drown menu (I have tried with both types but the behaviour is always the same).

I have read those threads:

https://appgini.bizzworxx.de/appgini/ap ... p-changes/
https://appgini.bizzworxx.de/appgini/ap ... selection/

and all posts related to custo tabs from https://appgini.bizzworxx.de/.

I have written some code and now I can show the tab I want to when I choose an option (radio button or drop-down menu) but when I save the record, the tab is not saved.
Another strange behaviour is this one: when I choose an option (radio button or drop-down menu), the fields of the tab are shown under the readio button field, not in the tab.

Here is my code:

(tabs 2, 3 and 4 are tabs previously defined)

// tabs not shown when adding the new record

tab2.fadeOut();
tab3.fadeOut();
tab4.fadeOut();

dv.ready(onReady);

function onReady() {

linked_to_init();
}

function linked_to_init() {

var fieldname = "linked_to";
var field = new AppGiniField(fieldname);

// register onChangeHandler (listener)

field.onChange(onLinkedToChanged);
}

function onLinkedToChanged(value) {
hideOrShowFields(value);
}

function hideOrShowFields(value) {

if (value == "risk") {
tab2.fadeIn();
tab3.fadeOut();
tab4.fadeOut();
}
if (value == "opportunity") {
tab3.fadeIn();
tab2.fadeOut();
tab4.fadeOut();
}
if (value == "goal") {
tab4.fadeIn();
tab2.fadeOut();
tab3.fadeOut();
}
}

Thanks in advance

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 899
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Hide/Show tabs with condition (radio button or drop-down)

Post by jsetzer » 2021-01-11 15:48

I recommend logging the value of value to first of all check if your function gets called at all.

As the change handler is a bonus feature, maybe this does not fire in this case of an options list displayed as radio buttons.

Concerning radio buttons and tabs: I am going to check that.
Kind regards,
<js />

balfons
Veteran Member
Posts: 47
Joined: 2018-10-22 15:27

Re: Hide/Show tabs with condition (radio button or drop-down)

Post by balfons » 2021-01-13 11:29

Hi Jan!

I checked that all functions are called properly and made some more tests (some fields where incorrectly defined). Now I'm at this point:

- the field "linked_to", which value has to trigger all the onChange is properly defined
- I have tested the code both hiding all tabs and showing them at the beginning (so I had these lines tab2.fadeOut(); tab3.fadeOut(); tab4.fadeOut(); ant the beginning as I told you in the first post and then I commented them)
- I have also tried setting the field "linked_to" both as a drop-down and radio button, but the behaviour is the same:

1) I select a value
2) The fields of the displayed tab are shown under the field "linked_to" in the main tab and the correct tab is shown
3) Save the record
4) The values of the fields are properly saved, as well as the value of the field "linked_to", but the tabs remain in the intial state: all shown or none shown

Thanks

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 899
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Hide/Show tabs with condition (radio button or drop-down)

Post by jsetzer » 2021-01-13 11:44

I need to have closer look at your specific scenario.

(1) Can you please send your code of hooks/TABLENAME-dv.js
(2) AND your .axp file by email to [email protected].

Before attaching, please rename .js file to .txt. Please do not post any public URL here.
Kind regards,
<js />

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 899
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Hide/Show tabs with condition (radio button or drop-down)

Post by jsetzer » 2021-01-14 07:46

I have answered your request by email.
Kind regards,
<js />

Post Reply