cancel
Showing results for 
Search instead for 
Did you mean: 

How to clear a combo box?

Former Member
0 Kudos

Hello,

I have a combo box with values.

I would like to create a button that by clicking it will clear the selection.

I tried to use:

wdContext.node<NodeName>().clearSelection();

But it doesn't clear the combo box. So how do I do it?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try this.

wdContext.current<<NodeElement>>.set<<Attrib>>("");

Regards, Anilkumar

Former Member
0 Kudos

Anilkumar's solution is Working 10q both

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Roy,

Using clear slection it only clears the current selection value. But if you want to remove all the contents Do one thing.

suppose your vie name is testview and node name is node1

in this node attribute is value1.

iprivatetestviw.inodenode1 n1 = wdcontext.nodenode1();

for (int i = n1.size() - 1; i >= 0; i--)

{

IPrivatetestView.Inode1Element myElement =

wdContext.nodeNode1().getNode1ElementAt(i);

wdContext.nodeNode1().removeElement(myElement);

}

Using this code you can clear your contents in node so in turn from Dropdown list.

Regards,

Bhavik

Former Member
0 Kudos

He wanted to clear the selection only.

To remove all node elements, I would use node.bind(null).

Armin

Former Member
0 Kudos

Hey Armin,

Can you please show me an exact code exaple of your explanation? It looks usefull...

Former Member
0 Kudos

Which one?

Armin

Former Member
0 Kudos

IWDDropDownByKey

Former Member
0 Kudos

Javadoc for IWDAbstractDropDownByKey explains how data binding works:

<b>Data binding:</b>

The set of selectable keys, displayed texts and the selected key are retrieved from a context. This context must provide an attribute y of a type having a value set. The selectable keys of the drop-down list are the keys of this value set, the displayed texts are the corresponding values. <b>The currently selected key is the current value of the attribute y</b>.

The property selectedKey must be bound to the attribute y.

Example: Let there be a root level attribute with name "Att" that contains the selected key and provides the value set. Then you must bind the "selectedKey" property of the drop-down list to attribute "Att". To clear the selection, use

wdContext.currentContextElement().setAtt(null)

Armin

Former Member
0 Kudos

10X I'll try that

Former Member
0 Kudos

What do you mean by "combo box"? I suppose you mean one of the two drop-down list box variants?

To clear the selection of a

- IWDDropDownByKey: Assign null to the context attribute to which property "selectedKey" is bound.

- IWDDropDownByIndex: Clear the lead selection (set to -1) of the context node which serves as data source.

Armin