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 toolbar 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 enableItem() and disableItem() to enable/disable toolbar items.

myToolbar.forEachItem(function(id){     //calling iterator         
    myToolbar.disableItem(id);          //your custom code, for example, disableItem()
});
 
 
//or
function doItemAction(id) {
    myToolbar.disableItem(id);          //your custom code, for example, disableItem()
}
myToolbar.forEachItem(doItemAction);    //calling iterator

Related sample:  Iterator

Listed Options Iterator

The method forEachListOption() calls a user-defined function for every listed option of a certain Select Button in the toolbar passing listed option's id into it.

myToolbar.forEachListOption(itemId, function(listOptionId){  // calling iterator 
     // your custom code, for example, setListOptionText()
    myToolbar.setListOptionText(id, listId, txt);       
});
 
 
// or
function doWithListOption(listOptionId){    
    // you custom code, for example, setListOptionText()
    myToolbar.setListOptionText(id, listId, txt);
}
myToolbar.forEachListOption(itemId, doWithListOption);       // calling iterator

Related sample:  Listed option iterator

Back to top