Check documentation for the latest version of dhtmlxSuite Using Iterator DHTMLX Docs

Using Iterator

The forEachItem() method calls a user-defined function for every existing item in the menu passing item's id into it. Using iterator can be very useful in case the user wants all the items to be subjects for the same changes. For example, you can use the methods setItemEnabled() and setItemDisabled() to enable/disable menu items.

myMenu.forEachItem(function(itemId){ // calling iterator
    myMenu.setItemDisabled(itemId);  // your code here, for example, setItemDisabled()
});
 
//or
function doItemAction(itemId) {      // your code here, for example, setItemDisabled()
    myMenu.setItemDisabled(itemId);
}
myMenu.forEachItem(doItemAction);    // calling iterator

Related sample:  Iterator

Back to top