FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



Nov 10, 2015, 6:11 AM
24 Posts

Hiding Various Fields-on selection Check box

  • Category: Server Side JavaScript
  • Platform: All
  • Release: All
  • Role: Developer
  • Tags:
  • Replies: 3

Hi Few days Back I got a Required to Disable a validation check on a combo box depending on a check box selection. I put the following in Disablevalidators of the combox

var status = getComponent('d_checkbox').getValue();

if (!status || status !== '0') {return true;} return false

means if the check box is not selected the field validator will work, if it is checked the field validator will be disable. It worked fine.

Now I have another requirement to hide the fields, combo box, labels etc on the same condition as above

I tried to put the Same in Visible Computed, it not hiding the fields when check box is enabled. 

var status = getComponent('d_checkbox').getValue();

if (!status || status !== '0') {return true;} return false

I am new in Xpages, I am learning and doing modifications, Can some one please help me how should I get this

 

Thanks

 

 

Nov 11, 2015, 7:33 AM
589 Posts
hmmm

Not sure I have a great answer.  I almost never use "getComponent" and do more of my validation in the save events.

 

if (!status || status !== '0'

 

I've never seen the "!==" before.  What does that do?  I would have thought you'd want "!="

Ideally if you could bind that checkbox to a viewScope variable then you could more easily see the value at any given time and have the visible/rendering of the things you want to hide read in the viewScope variable.

return viewScope.get("myVar");

 

Just a thought

 

Nov 16, 2015, 5:37 AM
24 Posts
Hiding Various Fields-on selection Check box

!== means not equal to

 

I also tried using

 

 

var _key1 = viewScope.get("iDraft") || @GetField("iDraft");

 

if(_key1 == "0"|| _key1 == "[0]" ){

true

}else {

false

};

 

but it's not hiding the field, any other logic to hide the field if check box in enabled

Nov 16, 2015, 5:37 AM
24 Posts
Hiding Various Fields-on selection Check box

!== means not equal to

 

I also tried using

 

 

var _key1 = viewScope.get("iDraft") || @GetField("iDraft");

 

if(_key1 == "0"|| _key1 == "[0]" ){

true

}else {

false

};

 

but it's not hiding the field, any other logic to hide the field if check box in enabled


FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.