serialize

serializes data to an array of JSON objects

array serialize(string|number rootId,boolean all);
rootIdstring|numberthe ID of the branch that will be serialized
allbooleandefines whether all data or only the filtered data are serialized
arrayserialized data as an array of JSON objects

Example

$$("tree1").serialize();

Details

By default, the whole tree data are serialized. If you want to serialize a particular branch, pass the ID of the branch to the method:

const branch_data = $$("tree1").serialize("branchId");

By default, only filtered data are serialized. If you want to serialize all data regardless of previous filtering, pass true as the second parameter:

$$("tree1").filter(function(obj){
  return obj.value.indexOf("IMG") !== -1;
});
const allData = $$("tree1").serialize(null,true);
Back to top
If you have not checked yet, be sure to visit site of our main product Webix javascript web framework and page of html treeview product.