【问题标题】:jstree: how to get the id of undetermined state of nodejstree:如何获取节点未确定状态的id
【发布时间】:2014-07-04 03:26:07
【问题描述】:

我使用 jstree('get_selected',false) 通过复选框插件获取我的 jstree 的选定节点,但结果不包括状态未确定的节点。 如何让所有选定的节点包括未确定的节点。

最新版本的jstree不包含'get_checked'方法,为什么?

谢谢。

【问题讨论】:

  • undetermined 状态由 jstree 在内部使用,并不意味着您可以检索、设置、过滤或更改。您必须修改 jsTree 插件(或扩展它)才能这样做。此外,我相信get_checked 已被get_selected() 取代,因为从技术上讲,他们现在也在做同样的事情。

标签: jquery plugins checkbox jstree


【解决方案1】:

jstree 版本 3 确实具有 get_selected 功能,它为您提供所有检查项目

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

对于未确定的节点,

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-10
    相关资源
    最近更新 更多