Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
Get All Selected Node values in JS Tree

I'm currently using js tree. I want to get the all selected node object.

Following is how I populate my jstree.

My JS Code

   $(function () {

        $('#data').jstree({
            'core': {
                'data': [
                    {
                        "text": "Administration",
                        "children": [
                            {
                                "text": "Admin",
                                "children": [
                                    {
                                        "text": "Access",
                                        "children": [
                                            { "id": "1", "text": "Add" },
                                            { "id": "2", "text": "Edit" },
                                            { "id": "3", "text": "Delete" },

                                        ]
                                    },

                                ]
                            }
                        ]
                    }
                ]
            },
            'checkbox': {
                three_state: false,
                whole_node: false,    // should be set to false. otherwise checking the hidden checkbox
                // could be possible by clicking the node
                tie_selection: false, // necessary for whole_node to work
                cascade: 'up down'
            },
            'plugins': ["checkbox"]


        },

        ).bind("loaded.jstree", function (event, data) {

            $(this).jstree("open_all");

            $('.btnGetCheckedItem').click(function () {
                var checked_ids = [];
                var selectedNodes = $('#data').jstree("get_selected", true);
                console.log(selectedNodes);
                $.each(selectedNodes, function () {
                    /*  console.log(this.original);*/
                    checked_ids.push(this.id);
                });

                
                $('#idshow').text(checked_ids);
            });

        });

    });

HTML

  <div id="data"></div>
  <input class="btnGetCheckedItem" value="Get all checked items" type="button" />

I am trying this code but I am not getting the selected node object. I am taking this from the jstree documents Please let me know if you have any idea where I am doing something wrong?

Thank you

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda