Extjs 4.1 學習筆記(一)(proxy,loader,treestore)


Ext.data.HttpProxy在Extjs 4中為Ext.data.proxy.Ajax,Ext.data.HttpProxy的用法在5.0后會取消

 

將頁面加載到panel中

Ext.create('Ext.panel.Panel', {
itemId: ‘itemid’,
title: ‘title’,
loader: {
    url: taget_url,
    autoLoad: true,
    scripts: true,
    params: { key: _trans.text }
}

參數params會post到頁面

 

在Extjs4.1中proxy需要使用post傳參數的話如下:

Ext.create("Ext.data.Store", {
       fields: [
           { name: 'fields_name', mapping: 'code_c' },
           { name: 'fields_code', mapping: 'code_field_intable' }
       ],
       storeId: 's_ds',
       autoLoad: true,
       proxy: {
           type: 'ajax',
           url: 'page.aspx',
           actionMethods: { read: 'POST' },//參數會post到頁面
           reader: 'json',
           extraParams: { key: 'key' }
       }
   })

 

Ext.create('Ext.data.TreeStore',{
    //nodeParam : 'parentId',  //這個屬性是異步加載主要特征,通過該節點去請求子節點,這個屬性不設置,默認傳到頁面的key就是node
    proxy: {
        type: 'ajax',
        url: '../getdata/GetNavTree.aspx',
    },
    // 設置根節點
    root: {
        text: '根節點',
        id: 'Branch',
        expanded: true
    }
});

這樣tree的節點就會動態加載,當然在server端還是要處理的

if (Request["node"] == "Branch") then

{

返回包含Branch的json數據

}elseif(Request["node"] == "leaf")

{

返回包含leaf的json數據

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM