adds an item to Sidebar
itemConf | object|array | object with item config (or array for several items) |
// initialize sidebar
var mySidebar = new dhtmlXSideBar({
parent: "sidebarObj",
template: "details",
icons_path: "icons/16x16/",
width: 160,
items: [
{id: "a1", text: "Item 1", icon: "image1.png", selected: true},
{id: "a2", text: "Item 2", icon: "image2.png"}
]
});
// add one new item
mySidebar.addItem({
id: "b1",
text: "New Item 1",
icon: "image1.png"
});
// to add several items at once, use an array
mySidebar.addItem([
{id: "b1", text: "New Item 1", icon: "image1.png"},
{id: "b2", text: "New Item 2", icon: "image2.png"}
]);
// to add a separator, use the "type" property
mySidebar.addItem([
{id: "b1", text: "New Item 1", icon: "image1.png"},
{id: "b2", text: "New Item 2", icon: "image2.png"},
{type: "separator"},
{id: "b3", text: "New Item 3", icon: "image3.png"}
]);
if you're going to remove separator by using the removeSep() method, you should also specify id for the separator
Back to top