Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Jared Sharen on Jul 20, 2009 08:26
open dhtmlx forum
Toolbar - getItemText

I am attempting to retreive the currently selected text value on a select options.

I am using:

<script>
var toolbar = new dhtmlXToolbarObject("toolbar","dhx_blue");
toolbar.loadXML("$vboptions[bburl]/clientscript/sweepscripts/file.xml",function(){

});
toolbar.attachEvent("onClick", function(id){
alert(id);
alert(toolbar.getItemText(id));

});
</script>

The onclick event fires, alerting me to the id of the element I selected, however the second alert returns an empty popup.

I am using XML to populate the list which looks like:

<?xml version="1.0"?>
<toolbar>
    <item id="type" type="buttonSelect" text="Type:">
        <item type="button" id="1" text="New Sweeps"/>
<item type="button" id="2" text="Expiring Sweeps"/>
<item type="button" id="3" text="Active Sweeps"/>
        <item type="button" id="4" text="Favorites"/>
<item type="button" id="5" text="Hidden Sweeps"/>
</item>
<item id="sep01" type="separator"/>
    <item id="category" type="buttonSelect" text="Type:">
        <item type="button" id="10" text="One Time"/>
<item type="button" id="11" text="Daily"/>
<item type="button" id="12" text="24-Hour"/>
<item type="button" id="13" text="Weekly"/>
<item type="button" id="14" text="7-Days"/>
<item type="button" id="15" text="Monthly"/>
<item type="button" id="16" text="Unlimited"/>
<item type="button" id="17" text="Unknown"/>
<item type="button" id="18" text="Weekdays"/>
    </item>
</toolbar>

Any idea's why this would not work? Thanks in advance for the help!!
Answer posted by Alex (support) on Jul 20, 2009 09:59

Hello,

there is getListOptionText(parent_id,id) method that should be used in the case of select options. But it is an actual issue to get a parent id of an option.

Please, try to use the following approach as a workaround (the next toolbar version will contain a public solution for that):

webBar.attachEvent("onClick",function(id){
  if (webBar.getType(id) == "buttonSelectNode" &&
webBar.getTypeExt(id) == "button") { 
    pid = String(webBar.objPull[webBar.idPrefix+id]["obj"]["parentObj"]["id"]).replace(webBar.idPrefix,"");
    text = webBar.getListOptionText(pid, id);
  }
  else text = webBar.getItemText(id);
  alert(text)
});