cancel
Showing results for 
Search instead for 
Did you mean: 

making textbox visible when checkbox marked

Former Member
0 Kudos

Hi, I have Textbox child and a Checkbox child with context of type boolean. I made a TextboxVISIBLE context of type Visibility and binded it to "enabling" option of Textbox. Now how can i bind it checkbox with textbox so once I mark checkbox the Textbox appears, unmarked dissapears. Regards, Balmer.

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member214651
Active Contributor
0 Kudos

Hi Balmer,

After u create the checkbox and bind it to an attribute of type binary

create a textbox and bind the "visible" property of the textbox to an attribute of type "VISIBILITY", and in the action of the checkbox write the following piece of code:

onActionClickCheckBox()

{

-


>if(blnCheck)

-


>{

-


>wdContext.currentContextElement.setTextBoxVisibility(WDVISIBILITY.VISIBLE);

-


>}

-


>else

-


>{

-


>wdContext.currentContextElement.setTextBoxVisibility(WDVISIBILITY.NONE);

-


>}

}

Hope this helps u now

Regards,

Poojith MV

Former Member
0 Kudos

Context:

- textVisibility (calculated attribute, type=Visibility)

- checked (boolean)

Data binding:

CheckBox.checked -> checked

CheckBox.onToggle -> Some action

TextView.visible -> textVisibility


WDVisibility getTextVisibility(IContextElement element)
{
  return element.getChecked() ? WDVisibility.VISIBLE : WDVisibility.NONE;
}

The empty action is only needed if you want to update the visibility immediately on each check box toggling.

Armin

Former Member
0 Kudos

doesn't work, I must be doing some mistake. Will look deeper into it. Thanks for help

Former Member
0 Kudos

Hi,

"I have Textbox child and a Checkbox child with context of type boolean. I made a TextboxVISIBLE context of type Visibility and binded it to "enabling" option of Textbox. Now how can i bind it checkbox with textbox so once I mark checkbox the Textbox appears, unmarked dissapears"

Checkbox should have an action "onToggle" associated with it.


//Check its selected or not,  change the code to align with your context attributes.


if(wdContext.currentContextElement().getSelected())
{
   //Assuming the name of the context attribute that is bound to the visible property is "TextBoxVisibility"
     wdContext.currentContextElement().setTextBoxVisibility(WDVisibility.VISIBLE);
}
else
{
wdContext.currentContextElement().setTextBoxVisibility(WDVisibility.NONE);

}

Regards

Ayyapparaj

Former Member
0 Kudos

Thanks for answers. It works other way around, once I mark checkbox the textbox dissappears (since it was visible after application starts). Changing VISIBLE and NONE options with each other in code does not work of course.

Once I add to:


public void wdDoInit()
  {
    //@@begin wdDoInit()
	wdContext.currentContextElement().setTextBoxVisibility(WDVisibility.NONE)
    //@@end
  }

to make it not visible when application starts like I want it then in that case once I mark checkbox it does not respond (textbox not appeared), unmarking does not make it appeared as well. Shall I code something in Selected method? Regards, Balmer.

Former Member
0 Kudos

hai balmer,

1. create two context attributes.1 of type visible and another of type boolean

2.now set the visible property of text box to the 1st attribute of context of type visible and set the checked property of the checkbox to the context attribute of type boolean.

3.create a method and call that method in ontoggle action of checkbox

4.In the method check if the check box value is true or false(checked or unchecked)

5.If its true then set the 1st attribute to wdvisibility.visible.

Any issues in this plz let me know

Thanks n Regards

Sharanya.R