Check documentation for the latest version of dhtmlxSuite addItem DHTMLX Docs


adds a new item to Accordion

void addItem(string|number id,string text, [boolean open,number height,string icon] );


idstring|numberitem's id
textstringitem's text
openbooleanoptional, open cell on init
heightnumberoptional, item's height (multi mode only)
iconstringoptional, path to icon


var myAcc = new dhtmlXAccordionObject(...);
// adding items
myAcc.addItem("item_a", "The Secret of Monkey Island", true, null, "icon.png");
myAcc.addItem("item_b", "Monkey Island 2: LeChuck's Revenge");
myAcc.addItem("item_c", "The Curse of Monkey Island");


If the parameter "open" isn't specified, the default behaviour is:

  • single mode - true for the 1st item (i.e. opens the 1st added item);
  • multimode - true for all items.

The parameter "height" in the multi mode can have the "*" value (means "auto"). In this case the logic will be the following:

For example, you have a multi mode accordion attached to a window with 3 autoheight cells. When all the cells are expanded, each cell has 1/3 of window's height. When one of them collapsed, each expanded cell will have 1/2 of window's height minus the height of the collapsed cell. If two cells collapsed - the expanded cell will occupy all the available space.

Change log

params: open, height and icon - added in 4.0

Back to top