Skip to main content

beforeItemLoad

fires before loading an item

info

The event fires when you load items via the loadItems() method of Tree Collection. The method also fires if you enable the autoload property of Tree.

beforeItemLoad:({ id: string | number }) => boolean | void;

Parameters:

  • id: string | number - the id of the item to load

Returns:

Return false to prevent loading of an item; otherwise, true.

Example

component.data.events.on("beforeItemLoad", function(id){
console.log("An ", id, " item will be loaded");
return false;
});
info

In case of error, the loadError event will fire.

note

If you block the auto-load for a Tree folder, the folder will be defined as a file after you try to open it.

To prevent this behavior, change the logic of the folders' definition via the isFolder property:

const tree = new dhx.Tree("tree_container", {
isFolder: obj => obj.items,
autoload:"https://docs.dhtmlx.com/suite/backend/autoload"
});

Change log:

added in v8.0