each

executes a defined function for each element of an array

void each(function functor, [object master] );

Deprecated

The PowerArray mixin will be removed in Webix 7.0

Parameters

functorfunctionthe function that needs executing
masterobjectoptional, the value to be passed as the this parameter

Example

var data = webix.toArray(grid_data);
 
// default
data.each(function(obj){
  console.log(this.length)  // the function is applied to the array itself
});
 
 
// binding to the datatable
webix.ui({
  view:"datatable",
  id:"grid",
  autoConfig:true
});
 
data.each(function(obj){
  if (obj.id%2 == 0)
    this.add(obj)
}, $$("grid"));  // the function is applied to the bound datatable

Related samples

Details

In the first example the defined function is applied to the data array of data objects. In the second example the defined function is applied to a grid view that is bound to the data array.

See also
Back to top