【问题标题】:ExtJS treepanel not getting real children itemsExtJS treepanel 没有得到真正的子项
【发布时间】:2014-11-18 02:06:52
【问题描述】:

我在ExtJS 4.2.1. 中有一个树形面板

树数据显示在面板中,但每次展开节点时,我都会在节点下方获得相同的信息,因此无限。

我没有得到真正的儿童物品。您可以理解 json 响应具有父节点的子节点,但不知何故,每次我展开一个节点时,都会完成对我的服务的 ajax 调用,因此我再次获得所有树数据结构。

这是我的 json:

[
    {
      "text": "QUALITY AREA",
      "cls": null,
      "expanded": false,
      "checked": false,
      "leaf": false,
      "children": [
        {
          "text": "JUNIOR A",
          "cls": null,
          "expanded": false,
          "checked": false,
          "leaf": true,
          "children": null
        }
      ]
    },
    {
      "text": "HUMAN RESOURCES",
      "cls": null,
      "expanded": false,
      "checked": false,
      "leaf": false,
      "children": [
        {
          "text": "SENIOR C",
          "cls": null,
          "expanded": false,
          "checked": false,
          "leaf": true,
          "children": null
        }
      ]
    },
    {
      "text": "IT DEPARTMENT",
      "cls": null,
      "expanded": false,
      "checked": false,
      "leaf": false,
      "children": [
        {
          "text": "JUNIOR E",
          "cls": null,
          "expanded": false,
          "checked": false,
          "leaf": true,
          "children": null
        }
      ]
    },
    {
      "text": "TRAINING",
      "cls": null,
      "expanded": false,
      "checked": false,
      "leaf": false,
      "children": [
        {
          "text": "JUNIOR F",
          "cls": null,
          "expanded": false,
          "checked": false,
          "leaf": true,
          "children": null
        }
      ]
    },
    {
      "text": "BENEFITS & COMP",
      "cls": null,
      "expanded": false,
      "checked": false,
      "leaf": false,
      "children": [
        {
          "text": "SENIOR D",
          "cls": null,
          "expanded": false,
          "checked": false,
          "leaf": true,
          "children": null
        }
      ]
    },
    {
      "text": "ADMIN",
      "cls": null,
      "expanded": false,
      "checked": false,
      "leaf": false,
      "children": [
        {
          "text": "CHIEF A",
          "cls": null,
          "expanded": false,
          "checked": false,
          "leaf": true,
          "children": null
        }
      ]
    }
  ],

这是我的树形面板:

{
                xtype: 'treepanel',
                itemId: 'treepaneltest',
                store: store,
                rootVisible: false,
                useArrows: true,
                frame: true,
                title: 'Check Tree',
                width: 500,
                height: 250,

            }

我是否必须更改我的 json 中的某些内容?

【问题讨论】:

  • 需要设置loaded: true,否则展开节点时会再次尝试加载。
  • 我必须在哪里设置该属性?
  • 在您的 json 中添加 'loaded:true' 属性,如 'checked'

标签: extjs extjs4 extjs4.1 extjs4.2


【解决方案1】:

你能介绍一下商店吗?

理想情况下,树形存储应如下所述。

Ext.define('MyApp.store.Hierarchies',{
    extend: 'Ext.data.TreeStore', 
    model : 'MyApp.model.Hierarchy',
    proxy: {
        type: 'ajax',
        url: 'path-to-json-file.json',
    },

    root: {
       text: 'Root',
       id: 'root',
       iconCls: 'cls',
       expanded: false,
    }

});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多