Skip to Content
0
Former Member
Jul 21, 2005 at 12:40 PM

How to bind a DropDown to something other than the lead selection?

62 Views

Hi everybody,

I want to build a toolbar dynamically.

The context structure looks like this:

ToolbarButtons (non-singleton node)
  |
  +Items (non-singleton node)
  |  |
  |  +Text (string)
  |  +Value (string)
  |
  +Text (string)
  +Tooltip (string)
  +Type (int)

Each ToolbarButtonsElement with Type=1 represents a ToolbarButton, each ToolbarButtonsElement with Type=2 should be a ToolbarDropDownByIndex. If so, the Items in the DropDown are stored in Items node.

I create the UI Elements with the following code:

for (int i = 0; i < tbNode.size(); i++)
{
	IToolbarButtonsElement tbe = 
		(IToolbarButtonsElement)tbNode.getElementAt(i);

	IWDToolBarItem tbItem = null;
	if (tbe.getType() == TOOLBAR_TYPE_BUTTON){ (...) }
	else if (tbe.getType() == TOOLBAR_TYPE_DROPDOWN)
	{
		wdContext.nodeHeaderData()
			.nodeToolbarContents()
			.nodeToolbarButtons()
			.setLeadSelection(i);
		IWDToolBarDropDownByIndex tbDD = 
			(IWDToolBarDropDownByIndex)view.createElement(
				IWDToolBarDropDownByIndex.class, null);
				
		tbDD.setLabelText(tbe.getText());
		tbDD.setTooltip(tbe.getTooltip());
				
		IWDAttributeInfo ai = wdContext.nodeHeaderData()
			.nodeToolbarContents()
			.nodeToolbarButtons()
			.nodeItems()
			.getNodeInfo()
			.getAttribute("Text");

		tbDD.bindTexts(ai);
		tbItem = tbDD;
	}
	if (tbItem != null) tb.addToolBarItem(tbItem);
}

This works fine if I only have one dropdown. But if there is more than one, all the items of ALL dropdowns display the (same) Items of the last element of ToolbarButtons.

If I change the lead selection of ToolbarButtons, all the dropdown items change as well.

How can I bind the DropDown Texts to something other than the lead selection?

best regards,

Markus