gijgo icon indicating copy to clipboard operation
gijgo copied to clipboard

The method tree.getAll() does not return the elements correctly

Open franlopezraris opened this issue 5 years ago • 0 comments

I need the tree object to return all nodes to me when one of them is moved. I have the following code:

    tree.on('nodeDrop', function (e, id, parentId, orderNumber) {
        var node = tree.getDataById(id);
        if (node.children.length > 0) {
            swal("Error!", "No es posible mover la familia a ese nodo", "warning");
            tree.reload();
            return false;
        }
        if (parentId) {
            $.ajax({
                type: 'GET',
                url: '/Carta/CheckIfPosibleMove/' + '@Model.idcarta' + '/' + parentId,
                dataType: 'json',
                contextType: "application/json",
                traditional: true
            }).done(function (esPosible) {
                if (esPosible === true) {
                    updatePadre(id, parentId);
                    saveOrdenFamilias(tree.getAll());
                    return true;
                } else {
                    swal("Error!", "No es posible mover la familia a ese nodo", "warning");
                    tree.reload();
                    return false;
                }
            });
        } else {
            updatePadre(id, '0');
            saveOrdenFamilias(tree.getAll());
            return true;
        }
    });

When calling the tree.GetAtll () function within the 'nodeDrop' event, it does not return the current order, but the one before the node movement.

franlopezraris avatar Oct 16 '20 16:10 franlopezraris