DHTMLX Docs & Samples Explorer

Iterator

Commonly enough developers need to use iterators in their code. It's useful when you need to apply the same operation to all items. So we decided to give this subject individual consideration.

The method forEachItem() calls a user-defined function for every existing item and passes an item's object into it. For example, you can use the hideHeader() method to hide headers of all items in the layout:

  <script>
      // calling iterator
      dhxLayout.forEachItem(function(item){
          // actions, for example:         
          item.hideHeader();
       });
  </script>
 
  //or
 
  <script>
      function doItemAction(item) {
          // actions, for example:
          item.hideHeader();
      }
      // calling iterator
      dhxLayout.forEachItem(doItemAction);
  </script>