zoukankan      html  css  js  c++  java
  • easui tree载入时自动展开无子节点的节点

    利用loadFilter对后台返回的原始数据进行过滤处理,将数据中的state字段修改相应的值,若无子节点,则改成open,若有子节点,则改成closed。

    由于一个node属性只有下面几项内容,因此利用checked字段,于是有了下面的sql查询语句,

    • id: An identity value bind to the node.
    • text: Text to be showed.
    • iconCls: The css class to display icon.
    • checked: Whether the node is checked.
    • state: The node state, 'open' or 'closed'.
    • attributes: Custom attributes bind to the node.
    • target: Target DOM object.
    string sql = "SELECT     id,  text, 是否有子节点 as checked FROM table where  父节点 =@father";


    前台javascript语句:

    $(function () {
                $('#tree').tree({
                    animate: true,
                    url: 'handler/PostDataHandler.ashx?type=9',
                    lines: true,
    
                    loadFilter: function (data, parent) {
                        for (var i = 0; i < data.length; i++) {
                            if (data[i].checked == "False") {
                                data[i].state = "open";
                            }
                        }
                        return data;
                    }
                });
            })



  • 相关阅读:
    iOS -- @try
    javaScript学习
    iOS -- js与原生交互
    iOS -- WKWebView
    iOS -- UIWindow的使用
    iOS -- app生命周期中代理方法的应用场景
    iOS -- keyChain
    UISegmentedControl
    明天你好
    编程:是一门艺术(转)
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3201424.html
Copyright © 2011-2022 走看看