Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted on Jun 14, 2009 04:29
open dhtmlx forum
setwidth of TB_new

Hi,

I have a problem with the toolbar and maybe you can help me out.
On my page I succesfully initialized the toolbar with:

var toolbar = new dhtmlXToolbarObject("toolbar","dhx_blue");
    toolbar.setIconsPath("icons/");
    toolbar.loadXML("toolbar.xml");

So far, so good.. however, as soon as I try to set the width of a buttonselect item, the script crashes.
on your sample and documentation database I have found this syntax:

webBar.setWidth(itemId, width);
Therefore my line of code was: toolbar.setwidth("TB_new",''100");
however, the script crashes as soon as I add this line. Dreamweaver does not show the parameter itemID.. you can only add the width.

I already tried a couple of things, but I do not seem to get it to work.

<?xml version="1.0"?>
    <toolbar>
        <item id="text" type="text" text="Nieuw:" />
        <item id="TB_new" type="buttonSelect" img="new.gif" imgdis="new_dis.gif" text="Contactpersoon">
            <item type="button" id="9_1" text="Contactpersoon"/>
            <item type="button" id="9_2" text="Bedrijf"/>
            <item type="button" id="9_3" text="Afspraak" enabled="false"/>
            <item id="9_sep0" type="separator"/>
            <item type="button" id="9_4" text="Anders..." enabled="false"/>
        </item>
        <item id="sep4" type="separator"/>
        <item id="text" type="text" text="Zoeken in:" />
        <item id="searchObject" type="buttonSelect" img="iconSearch.gif" text="Contactpersoon">
            <item type="button" id="8_1" text="Contactpersoon" selected="true"/>
            <item type="button" id="8_2" text="Bedrijf"/>
            <item id="8_sep0" type="separator"/>
            <item type="button" id="8_5" text="Anders..." enabled="false"/>
        </item>
        <item id="txt_2" type="buttonInput" value="" width="100" title="type the text here"/>
</toolbar>
Answer posted by Alex (support) on Jun 15, 2009 00:51

Hello,

Please, check that  you call setWidth after xml loading:

toolbar.loadXML("toolbar.xml",doAfterXMLLoading);

function doAfterXMLLoading(){

   toolbar.setWidth("TB_new",''100");

}

Also you should check the case of the setWidth method (as you whote toolbar.setwidth("TB_new",''100");).

Please, take a look at the attached sample - http://dhtmlx.com/docs/products/dhtmlxToolbar/samples/button_select/width.html

Answer posted on Jun 15, 2009 03:34
Hello,

Is it also possible to incorporate some parameter in the XML file to take care of this issue?
There is actually no real need to resize the object, if the buttonSelect can already initialize with the correct width..

Cheers and thanks for your help
Answer posted on Jun 15, 2009 03:45
By the way, the provided solution works like a charm!