ext.一边tree,一边grid的例子,点击tree可以更改gird的内容

var win = desktop.getWindow('user-mag');
        //var sm = new Ext.grid.CheckboxSelectionModel();
        if(!win){   
            //ds_qr.load();
            win = desktop.createWindow({
                id: 'user-mag',title:'人员确认',width:780,height:530,
                cls:"test1",iconCls: 'icon-grid',
                shim:false,animCollapse:false,constrainHeader:true,layout: 'border',
                items: [
                    mytree = new Ext.tree.TreePanel({
                       title:'单位列表',region:'west',split:true,width: 200,collapsible : true,height:520,
                       margins: '3 0 3 3',cmargins:'3 3 3 3',border:false, ddScroll:true,autoScroll:true,
                       animate:true,collapsible:true,enableDD:true,enableDrag:true,rootVisible:true,
                       lines:true,
                       loader:new Ext.tree.TreeLoader({
                        dataUrl:"json_tree.asp"
                       }),
                       root:new Ext.tree.AsyncTreeNode({
                           id:"root",
                           text:"香洲区学校",
                           expanded:true
                       }),
                       listeners:{
                            "loadexception":function(loader,node,response){
                                node.loaded = false;
                                node.reload.defer(10,node);//不停的加载,直到true
                            },
                            "click":function(node){
                                     //ds_ryxx.url=jsonurl+"?sql="+escape("select id,xming from v_ryxx where dwei="+ node.id);
                                    ds_ryxx.proxy = new Ext.data.HttpProxy({url : jsonurl+"?sql="+escape("select id,xming from v_ryxx where dwei="+ node.id)});
                                    ds_ryxx.load({params:{start:0,limit:pagesize,sql:escape("select id,xming from v_ryxx where dwei="+ node.id)}});
                            }
                        }
                    }),//tree
                    new Ext.grid.GridPanel({
                        title:'单位列表',region:'center',width: 230,collapsible : true,
                        margins: '3 0 3 3',cmargins:'3 3 3 3',border:false,
                        id:'gp_qr',store:ds_ryxx,
                        cm: new Ext.grid.ColumnModel([
                            new Ext.grid.RowNumberer({header:"编号",width:40}),
                            {header: "id", width: 20, sortable: true, dataIndex: 'id',hidden:true},
                            {header: "姓名", width: 70, sortable: true, dataIndex: 'xming'}
                        ]),
                        viewConfig: {
                            forceFit:true
                        },
                        bbar:new Ext.PagingToolbar({//人员列表的分页条
                            displayInfo:true,emptyMsg:"没有数据显示",displayMsg:"显示从{0}条数据到{1}条数据,共{2}条数据",
                            store:ds_ryxx,
                            pageSize:pagesize
                        })//PagingToolbar
                    })//GridPanel                               
                ]//items
            })//createWindow
        } //if
        //win.setPosition(100.100);
        mytree.render();
        win.show();

//关键在于proxy的两句代码

你可能感兴趣的:(sql,json,ext,asp)