留言板

Duplicated nodes in TreeView when lazy-loading (IO) is employed

Jan Tošovský,修改在10 年前。

Duplicated nodes in TreeView when lazy-loading (IO) is employed

Liferay Master 帖子: 566 加入日期: 10-7-22 最近的帖子
Dear All,

I've found that TreeView in my portlet updated to LR 6.2 CE works incorrectly.

That treeData variable stores JSON tree with TOC like structure (links to articles). When any collapsed node is expanded, the tree is updated (correctly). When any link is clicked and the new page is dispayed, the treeView variable is rebuilt from the scratch. It contains only relevant nodes - ancestors and their siblings.

But all previous lazy loaded data seems to be somehow cached and injected into this structure afterwards so these node are duplicated!!!
When tracing the treeData JSON data, they are really correct. It has to be JavaScript who renders the tree incorrectly.

Is there something to fix in my code?

<div id="tree">
    <aui:script use="aui-tree-view, datatype-xml, dataschema-xml">
        var tree = new A.TreeView({
                type: 'normal',
                boundingBox: '#tree',
                children: &lt;%= treeData %&gt;,
                io: {
                        cfg: {
                                data: function(node) {
                                        return {
                                            p_auth: Liferay.authToken,
                                            parentId: node.get('id')
                                        };
                                },
                                method: A.config.io.method
                        },
                        url: '/c/myra_tree/get_tree_fragment?nodeId=&lt;%= nodeId %&gt;' 
                }			
        })
        .render();
    </aui:script>
</div>


Thanks, Jan
Jan Tošovský,修改在10 年前。

RE: Duplicated nodes in TreeView when lazy-loading (IO) is employed

Liferay Master 帖子: 566 加入日期: 10-7-22 最近的帖子
I've just found the difference between 6.1 and 6.2:

When the page is loaded, in 6.2 all expanded nodes call that IO function so the corresponding node content is unexpectedly lazy-loaded and hence duplicated.

In 6.1 IO function is not called in this step.

How can I disable this auto lazy-loading?

Here is an example of my JSON data:

[
   {
      "id":"d0e2",
      "label":"<a href="\&quot;http://localhost:8080/web/guest/user-manual/-/wiki/Main/Title+Page\&quot;">Title Page</a>"
   },
   {
      "id":"d0e4",
      "label":"<a href="\&quot;http://localhost:8080/web/guest/user-manual/-/wiki/Main/2+GUI\&quot;">GUI</a>",
      "expanded":true,
      "leaf":false,
      "type":"io",
      "children":[
         {
            "id":"d0e5",
            "label":"<a href="\&quot;http://localhost:8080/web/guest/user-manual/-/wiki/Main/2+GUI#first\&quot;">Toolbars</a>",
            "leaf":false,
            "type":"io"
         },
         {
            "id":"d0e9",
            "label":"<a href="\&quot;http://localhost:8080/web/guest/user-manual/-/wiki/Main/2.2+Dialogs\&quot;">Dialogs</a>",
            "expanded":true,
            "leaf":false,
            "type":"io",
            "children":[
               {
                  "id":"d0e10",
                  "label":"<a href="\&quot;http://localhost:8080/web/guest/user-manual/-/wiki/Main/2.2+Dialogs#first\&quot;">Configuration Change Dialog</a>",
                  "leaf":false,
                  "type":"io"
               },
               {
                  "id":"d0e33",
                  "label":"<a href="\&quot;http://localhost:8080/web/guest/user-manual/-/wiki/Main/2.2.2+Start+Job+Dialog\&quot;">Start Job Dialog</a>"
               },
               {
                  "id":"d0e34",
                  "label":"<a href="\&quot;http://localhost:8080/web/guest/user-manual/-/wiki/Main/2.2.3+Job+Information+Area\&quot;">Job Information Area</a>"
               },
               {
                  "id":"d0e35",
                  "label":"<strong>Log Area</strong>",
                  "expanded":true,
                  "leaf":false,
                  "type":"io",
                  "children":[
                     {
                        "id":"d0e36",
                        "label":"<a href="\&quot;http://localhost:8080/web/guest/user-manual/-/wiki/Main/2.2.4+Log+Area#first\&quot;">Log Area Context Menu</a>"
                     }
                  ]
               },
               {
                  "id":"d0e37",
                  "label":"<a href="\&quot;http://localhost:8080/web/guest/user-manual/-/wiki/Main/2.2.5+Queue+Mode\&quot;">Queue Mode</a>",
                  "leaf":false,
                  "type":"io"
               }
            ]
         }
      ]
   },
   {
      "id":"d0e41",
      "label":"<a href="\&quot;http://localhost:8080/web/guest/user-manual/-/wiki/Main/3+Command+Lines\&quot;">Command Lines</a>",
      "leaf":false,
      "type":"io"
   }
]
Jan Tošovský,修改在10 年前。

RE: Duplicated nodes in TreeView when lazy-loading (IO) is employed (答复)

Liferay Master 帖子: 566 加入日期: 10-7-22 最近的帖子
I've just found it gets fixed when 'type': 'io' is removed when 'expanded':true in JSON data.