changeId()
changes the id of an item of a tree collection
Usage
type Id = string | number;
changeId(id: Id, newId?: Id, silent?: boolean): Id;
Parameters:
id: Id- the old id of an itemnewId?: Id- optional, the new id; auto-generated if not setsilent?: boolean- optional, if set to true, the method will not trigger the change event; otherwise, false
Returns:
The new id of the item, or the original id if the change was rejected.
Example
// changing the id of an item
component.data.changeId("1", "22"); // -> "22"
// the child items of the item get the new parent id
component.data.getParent("1.1"); // -> "22"
// changing the id without triggering the change event
component.data.changeId("22", "33", true);
The child items of the item stay attached to it: their parent property takes the new id, also while a filter is applied.
The method leaves the item as is, shows a warning in the browser console and returns the original id in the following cases:
idornewIdis the id of the root item of the collection- the collection has no item with the
idid - an item with the
newIdid already exists newIdis not a valid id, that is, neither a number nor a non-empty string- the data is grouped
Related API: