Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to show or hide tab in dialog in cq5

Avatar

Level 2

Hi,

I have a requirement where based on radio button i need to show the tab when not selected i need to hide.

Please let me know how to achieve or examples please.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

By using the listener its quite easy to achieve your question. 

Step 1: give the tab to show/hide an ID

<tab2 jcr:primaryType="cq:Panel" title="tab2" itemId="tab2"> ... </tab2>

Step 2: add a listener to the selection which you want to handle:

If the selection is 'no' the tab will be disabled, otherwise enabled.

<select jcr:primaryType="cq:Widget" fieldLabel="ShowTab" name="./show" type="radio" value="yes" xtype="selection"> <options jcr:primaryType="cq:WidgetCollection"> <option1 jcr:primaryType="nt:unstructured" text="Yes" value="yes"/> <option2 jcr:primaryType="nt:unstructured" text="No" value="no"/> </options> <listeners jcr:primaryType="nt:unstructured" selectionchanged="function( field,value, isChecked ){ if (field !=null){ var d = field.findParentByType('tabpanel'); if (value == 'no'){ d.hideTabStripItem('tab2'); }else{ d.unhideTabStripItem('tab2'); } } }"/> </select>

View solution in original post

4 Replies

Avatar

Level 1

You can see the default list component (/libs/foundation/components/list). They have implemented this with dropdown and same can be done with radio buttons.

Avatar

Correct answer by
Former Community Member

By using the listener its quite easy to achieve your question. 

Step 1: give the tab to show/hide an ID

<tab2 jcr:primaryType="cq:Panel" title="tab2" itemId="tab2"> ... </tab2>

Step 2: add a listener to the selection which you want to handle:

If the selection is 'no' the tab will be disabled, otherwise enabled.

<select jcr:primaryType="cq:Widget" fieldLabel="ShowTab" name="./show" type="radio" value="yes" xtype="selection"> <options jcr:primaryType="cq:WidgetCollection"> <option1 jcr:primaryType="nt:unstructured" text="Yes" value="yes"/> <option2 jcr:primaryType="nt:unstructured" text="No" value="no"/> </options> <listeners jcr:primaryType="nt:unstructured" selectionchanged="function( field,value, isChecked ){ if (field !=null){ var d = field.findParentByType('tabpanel'); if (value == 'no'){ d.hideTabStripItem('tab2'); }else{ d.unhideTabStripItem('tab2'); } } }"/> </select>

Avatar

Level 1

Does this work ??

d.hideTabStripItem('tab2');

i believe it should be d.hideTabStripItem(1);

Avatar

Administrator

nitinh81834186 wrote...

Does this work ??

d.hideTabStripItem('tab2');

i believe it should be d.hideTabStripItem(1);

 

 

Excellent.  you are correct, the arguments must be index [hideTabStripItem(index) ].

~kautuk



Kautuk Sahni
The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----