2013-06-28 38 views
2

我正在使用Extjs树,我得到了点击嵌套节点ajax请求到服务器的问题,我知道这种延迟加载,但我的树不是很大,约35项,所以我想请求服务器时间只收集所有树节点和项目。 有什么想法?如何在没有Ajax请求的情况下展开树节点?

查看:

​​

})

商店:

Ext.define('CRM.store.RoleList', { 
extend: 'Ext.data.TreeStore', 
storeId: 'RoleTreeStoreId', 
//model: 'CRM.model.RoleList', 
autoLoad: false, 
proxy: { 
      type : 'ajax', 
      url : 'index.php/role/getRoleList', 
      async : false, 
      reader: { 
       type : 'json', 
       method : 'POST' 
      } 
}, 
root:{ 
    expanded:true, 
    text:"Organization", 
    leaf:'false', 
    id  : '/', 
} 

})

Json的回报:

{ 
"text": "Organization", 
"id": "role-1", 
"children": [ 
    { 
     "text": "Admin", 
     "id": "role-12", 
     "expanded": "true", 
     "children": [ 
      { 
       "text": "MSD", 
       "id": "role-23", 
       "children": [ 
        { 
         "text": "Customer Care Manager", 
         "id": "role-4", 
         "children": [ 
          { 
           "text": "Customer Care Adviser", 
           "id": "role-5" 
          } 
         ] 
        }, 
        { 
         "text": "Solution Adviser", 
         "id": "role-7" 
        }, 
        { 
         "text": "Sales Manager", 
         "id": "role-31", 
         "children": [ 
          { 
           "text": "Solution Sales", 
           "id": "role-6" 
          }, 
          { 
           "text": "Teritory 01 - Safy", 
           "id": "role-9", 
           "children": [ 
            { 
             "text": "Sales Person 01", 
             "id": "role-10" 
            }, 
            { 
             "text": "Sales Trainee 01", 
             "id": "role-26" 
            } 
           ] 
          }, 
          { 
           "text": "Teritory 3 - Sambo", 
           "id": "role-11", 
           "children": [ 
            { 
             "text": "Sales Person 3", 
             "id": "role-13" 
            } 
           ] 
          }, 
          { 
           "text": "Teritory 4 - Narong", 
           "id": "role-14", 
           "children": [ 
            { 
             "text": "Sales Team 4", 
             "id": "role-15", 
             "children": [ 
              { 
               "text": "Sales Person 4", 
               "id": "role-25" 
              } 
             ] 
            } 
           ] 
          }, 
          { 
           "text": "branch shv", 
           "id": "role-16", 
           "children": [ 
            { 
             "text": "sales shv", 
             "id": "role-19" 
            } 
           ] 
          }, 
          { 
           "text": "branch btb", 
           "id": "role-17", 
           "children": [ 
            { 
             "text": "sales btb", 
             "id": "role-20" 
            } 
           ] 
          }, 
          { 
           "text": "branch srp", 
           "id": "role-18", 
           "children": [ 
            { 
             "text": "sales srp", 
             "id": "role-21", 
             "children": [ 
              { 
               "text": "sales person srp", 
               "id": "role-28" 
              } 
             ] 
            } 
           ] 
          }, 
          { 
           "text": "Retention Program", 
           "id": "role-22", 
           "children": [ 
            { 
             "text": "Retention Program Analysist", 
             "id": "role-24" 
            } 
           ] 
          }, 
          { 
           "text": "Sales Trainee", 
           "id": "role-27" 
          }, 
          { 
           "text": "Enterprise Sales Engineer", 
           "id": "role-29" 
          }, 
          { 
           "text": "Meas Test", 
           "id": "role-30" 
          }, 
          { 
           "text": "Teritory 02 - Kol", 
           "id": "role-32", 
           "children": [ 
            { 
             "text": "Sales Person 02", 
             "id": "role-8" 
            } 
           ] 
          } 
         ] 
        } 
       ] 
      }, 
      { 
       "text": "CTO", 
       "id": "role-35", 
       "children": [ 
        { 
         "text": "Support Manager", 
         "id": "role-2", 
         "children": [ 
          { 
           "text": "Technical Support Adviser", 
           "id": "role-3" 
          } 
         ] 
        }, 
        { 
         "text": "IT BIlling Product Manager", 
         "id": "role-33", 
         "children": [ 
          { 
           "text": "IT Staff", 
           "id": "role-34" 
          } 
         ] 
        } 
       ] 
      }, 
      { 
       "text": "Business Consultant", 
       "id": "role-36" 
      } 
     ] 
    } 
] 

}

+0

向我们显示您的请求回复。 –

+0

我已经编辑提供代码示例 – Meas

回答

0

我发现我的错误与JSON,我应该添加属性“叶=真/假”根据有孩子或没有。

+0

标记问题为回答如果您满意答案提供 –

+0

非常感谢你 – Meas

0

您仍然可以使用异步调用,但只能使用一次。为了确保只有一个电话被打出,请在第一个电话中返回所有的孩子。 Extjs会加载所有提供的孩子。

相关问题