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数据

}

原文地址:https://www.cnblogs.com/wallis0922/p/2790551.html