2013-06-28 64 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會加載所有提供的孩子。

相關問題