winhell
winhell

Reputation: 481

jstree: how to get the id of undetermined state of node

I use the jstree('get_selected',false) to get the selected node of my jstree with checkbox plugins, but the result doesn't include the node with undetermined state . How can I get all of the selected node include undetermined ones.

the newest version of jstree does not include the method 'get_checked', why?

thanks.

Upvotes: 1

Views: 4588

Answers (1)

suomi-dev
suomi-dev

Reputation: 868

jstree version 3 does have get_selected feature and it gives you all checked items

        var selectedElements = $('#treeidhere').jstree("get_selected", true);
        // Iterate over all the selected items
        $.each(selectedElements, function () {
            alert(this.id);
        });

for undetermined nodes,

        var checked_ids = [];
        $("#treeidhere").find(".jstree-undetermined").each(function (i, element) {
            alert($(element).closest('.jstree-node').attr("id"));
            checked_ids.push($(element).attr("id"));
        });

Upvotes: 6

Related Questions