toolbar - selectbutton

I have three questions regarding the SelectButton



1- Using the xml configuration file, how would I set the initial state has “hidden” of a SelectButton?



2- What is the toolbar method (example please) to then set this SelectButton as “visible”?



3- Using the xml configuration file, how can I set an item in the SelectButton list as selected (it defaults to the top item in the list, but I would like to initially select a different item)



Thanks!



-Andrew

1- Using the xml configuration file, how would I set the initial state has “hidden” of a SelectButton?
There is no way to define button as hidden in XML. Button can be set only in disabled state ( by using “disabled” attribute )
Can be done by js command as
    toolbar.loadXML(url,function(){
       toolbar.hideItem(“some_id”);
    });

>>2- What is the toolbar method (example please) to then set this SelectButton as “visible”?
    toolbar.hideItem(id);
    toolbar.showItem(id);

>>3- Using the xml configuration file, how can I set an item in the SelectButton list as selected
    Not possible from XML, can be done only by js command
    toolbar.getItem(id).setSelected(value);

After I selected a list from selectButton, I used the following code to set selected item, but it does not work
toolbar.getItem(id).setSelected(true);

Boa

This approach was recommended 2 years ago.

The list of the latest toolbar methods is:

docs.dhtmlx.com/doku.php?id=dhtm … _toc_alpha

Try to use the setListOptionSelected method:
docs.dhtmlx.com/doku.php?id=dhtm … onselected

First time to use dhtmlxToolbar component. It works. Thanks.

I upgraded dhtmlx 2.1 to dhtmlx 2.5, now the following code to control selectbutton does not work. I works at dhtmlx 2.1. It seems I can not get itemId when it is from selectbutton list at the function onClickToolbarMenu. It works only clicking the first item “print_invoice”.

<link rel="stylesheet" type="text/css" href="../../dhtmlxcodebase2.5/dhtmlxLayout/codebase/dhtmlxlayout.css">

<link rel="stylesheet" type="text/css" href="../../dhtmlxcodebase2.5/dhtmlxLayout/codebase/skins/dhtmlxlayout_dhx_skyblue.css">
<link rel="stylesheet" type="text/css" href="../../dhtmlxcodebase2.5/dhtmlxWindows/codebase/dhtmlxwindows.css">
<link rel="stylesheet" type="text/css" href="../../dhtmlxcodebase2.5/dhtmlxWindows/codebase/skins/dhtmlxwindows_dhx_skyblue.css">
<script src="../../dhtmlxcodebase2.5/dhtmlxLayout/codebase/dhtmlxcommon.js"></script>
<script src="../../dhtmlxcodebase2.5/dhtmlxLayout/codebase/dhtmlxlayout.js"></script>
<script src="../../dhtmlxcodebase2.5/dhtmlxWindows/codebase/dhtmlxwindows.js"></script>

<script src="../../dhtmlxcodebase2.5/dhtmlxLayout/codebase/dhtmlxcontainer.js"></script>

	// Layout
	var dhxLayout = new dhtmlXLayoutObject("parentId", "3J");
	dhxLayout.cells("b").setWidth(600);
	
	toolbar = dhxLayout.cells("b").attachToolbar();
	toolbar.setIconsPath("../images/");

	var invoiceOpts = Array(
		Array('preview_invoice', 'obj', 'Preview Invoice', 'iconNew_dis.gif', 'iconNew_dis.gif'), 
		Array('send_invoice', 'obj', 'Send Invoice Email', 'Email_go.png', 'Email_go.png'),
		Array('testing', 'obj', 'Testing', 'Email_go.png', 'Email_go.png')
	);
	toolbar.addButtonSelect("print_invoice", 9, "Print Invoice", invoiceOpts, "print.gif", "print_dis.gif");
	// attach toolbar event 
	toolbar.attachEvent("onClick", onClickToolbarMenu);

	function onClickToolbarMenu(itemId) 
	{
		if (toolbar.getType(itemId) == "buttonSelectNode" && toolbar.getTypeExt(itemId) == "button") {
			pid = String(toolbar.objPull[toolbar.idPrefix+itemId]["obj"]["parentObj"]["id"]).replace(toolbar.idPrefix,"");
			text = toolbar.getListOptionText(pid, itemId);

// text = "List “+itemId+” was clicked. The text is "+toolbar.getListOptionText(pid, itemId);
}
else text = toolbar.getItemText(itemId);

		// Debug
		alert(text);
		switch (itemId) {
			case "print_invoice":
			case "preview_invoice":
			case "send_invoice":
				// debug
				alert(text);
				break;
			case "testing":
				// attaching an object to Panel b
				dhxLayout.cells("b").attachObject("objId1");
				// debug
				alert(text);
				break;
		}


	}

You may check toolbar samples. For example:

dhtmlxToolbar/samples/04_button_select/11_list_text.html