0

Hi i 'm trying to hide all nodes in jstree when the search has no results but I am getting the following error.

Uncaught TypeError: $(...).jstree(...).hide_all is not a function

Here is the code I use:

            $("#divtreeComponentes").jstree("destroy");
        $("#divtreeComponentes").jstree({
            "core": {
                // so that create works
                "check_callback": true,

                "data": data2
            },
            "checkbox": {
                "keep_selected_style": false
            },
            "search": {
                "show_only_matches": true,//filtering
                "show_only_matches_children": true

            },
            "types": {
                "types": {
                    "disabled": {
                        "check_node": false,
                        "uncheck_node": false
                    }
                }
            },
            "plugins": ["checkbox", "search", "sort"]
        }).on('search.jstree', function (nodes, str, res) {
            if (str.nodes.length===0) {
                $('#divtreeComponentes').jstree(true).hide_all();
            }
        })

        $('#Filtrar_Usuarios').keyup(function(){
            $('#divtreeComponentes').jstree(true).show_all();
            $('#divtreeComponentes').jstree('search', $(this).val());
        });

are any ideas that may be happening ?

thanks for helping!

Brian Schmidt
  • 11
  • 1
  • 4

1 Answers1

1

I solved the problem with this.

 $("#divtreeComponentes").jstree({
            "core": {
                // so that create works
                "check_callback": true,

                "data": data2
            },
            "checkbox": {
                "keep_selected_style": false
            },
            "search": {
                "show_only_matches": true, //filtering
                "show_only_matches_children": true

            },
            "types": {
                "types": {
                    "disabled": {
                        "check_node": false,
                        "uncheck_node": false
                    }
                }
            },
            "plugins": ["checkbox", "search", "sort"]
        }).on('search.jstree', function(nodes, str, res) {
            if (str.nodes.length === 0) {
                $('#divtreeComponentes').hide();
            }
        })

        $('#Filtrar_Usuarios').keyup(function() {
            $('#divtreeComponentes').show();
            $('#divtreeComponentes').jstree('search', $(this).val());
        });

$('#divtreeComponentes').hide(); Works for me!

Good luck!

Brian Schmidt
  • 11
  • 1
  • 4