Skip to main content

map()

iterates through all the items of the component

map(callback: function, id?: string | number, direct?: boolean): any;

Parameters:

  • callback: function - the function that will be applied to every item. The function is called with the following parameters:
    • item: object - the object of an item
    • index: number - the index of an item
    • array: object[] - an array of items the method was called upon
  • id?: string | number - optional, the ID of a control the child items of which will be included
  • direct?: boolean - optional, defines whether only direct children of the control will be included in the iteration

Example

toolbar.data.map ((item) => {
//remove all icons
item.icon = "";
});
toolbar.paint();

To work with all children of a particular control, pass one more parameter to map() - the ID of the control:

toolbar.data.map ((item) => {
// disable items
item.disabled = true;
}, "menu_1");
toolbar.paint();

If you want to iterate only through immediate children, set the third parameter to false:

toolbar.data.map ((item) => {
// add a css class to each item
item.css = "highlight";
}, "menu_1", false);
toolbar.paint();