mirinda95925 2009-12-03 14:07
浏览 259
已采纳

Ext panel为什么加载不进去

--------------------------------------布局----------------------------------

//布局管理
function createLayout(){
new Ext.Viewport({

layout:'border',

items:[{

title: '部门管理',

collapsible: true,

region:'west',

width: 100,
items:tree,
tbar:[{
id:'txt-name',
xtype:'textfield'
},{
xtype:'button',
text:'查找',
handler:searchTree
}]
},{

region:'center',
id:'tabs',
xtype:'tabpanel',
activeTab:0,
contentEl:'dms-content',
items:panels
}]

})

}

--------------------------------------panel----------------------------------

function createPanel(){
panels = Ext.extend(Ext.Panel, {
border:false,
layout:'fit',
pageSize:20, //分页大小
initComponent:function(){
panel.superclass.initComponent.call(this);
this.grid = this.createGrid(); //创建表格
//this.add(this.grid);
},
items:[{items:this.grid}],
/**
* 创建表格部件
*/
createGrid:function(){

    var ds = new Ext.data.JsonStore({
        url:'/KJ222Demo/Demo/getAll',   //由etmvc映射到DeviceController类中的getDevices方法
        fields:[
            'id','code','name','other'
        ],
        baseParams:{
            limit:this.pageSize
        },
        totalProperty:'total',
        root:'demo'

    });
    ds.load({
        params:{start:0}
    });
    var grid = new Ext.grid.GridPanel({
        store:ds,
        columns:[
            {header:'行号',renderer:function(value, cellmeta, record, rowIndex){return rowIndex + 1;}},
            {header:'编号',dataIndex:'code',width:100},
            {header:'名称',dataIndex:'name',width:100},
            {header:'其它',dataIndex:'other',width:100}

        ],
        tbar:[{
            text:'增加',

            iconCls:'tool-add'

        },'-',{
            text:'修改',
            iconCls:'tool-edit'

// iconCls:'tool-edit',
// handler:this.editItem.createDelegate(this)
},'-',{
text:'删除',
iconCls:'tool-cut'
// iconCls:'tool-cut',
// handler:this.destroyItem.createDelegate(this)
},'-',{
text:'查询',
iconCls:'tool-find',
handler:this.showQueryWindow.createDelegate(this)
},'-',{
text:'导出到excel',
iconCls:'tool-find',
handler:this.onPrint.createDelegate(this)
}],
bbar:new Ext.PagingToolbar({
store:ds,
pageSize:this.pageSize
}),
border:false
});
//grid.render('grid-example');
//grid.getSelectionModel().selectFirstRow();

    return grid;
}

});}
---------------------------------------问题------------------------------------
},{

region:'center',
id:'tabs',
xtype:'tabpanel',
activeTab:0,
contentEl:'dms-content',
items:panels
}]

items:panels
没反应

[b]问题补充:[/b]
var tree;
var panels;

已经定义了,用FF调试,到createGrid:function(){ 这里时就断掉了。

[b]问题补充:[/b]
this.grid = this.createGrid(); //创建表格
this.add(this.grid);
定义了。不管怎么调都出来了。。
郁闷

  • 写回答

5条回答 默认 最新

  • xkuff 2009-12-03 23:08
    关注

    因为没有执行initComponent函数,以下是我的修改,不知道是否合适,有部份代码被注释了,是因为我这边没有全部的代码。
    [code="JavaScript"]
    var tree;
    var panels;
    //布局管理
    function createLayout(){
    new Ext.Viewport({

    layout:'border',

    items:[{

    title: '部门管理',

    collapsible: true,

    region:'west',

    width: 200,
    items:tree,
    tbar:[{
    id:'txt-name',
    xtype:'textfield'
    },{
    xtype:'button',
    text:'查找',
    handler:function(){}
    }]
    },{

    region:'center',
    id:'tabs',
    xtype:'tabpanel',
    title:'123123',
    activeTab:0,
    contentEl:'dms-content',
    items:panels
    }]

    })
    }
    function createPanel(){
    var ds = new Ext.data.JsonStore({
    url:'/KJ222Demo/Demo/getAll', //由etmvc映射到DeviceController类中的getDevices方法
    fields:['id','code','name','other'],
    baseParams:{limit:this.pageSize},
    totalProperty:'total',
    root:'demo'
    });
    //ds.load({params:{start:0}});
    grid = new Ext.grid.GridPanel({
    height:300,
    store:ds,
    columns:[
    {header:'行号',renderer:function(value, cellmeta, record, rowIndex){return rowIndex + 1;}},
    {header:'编号',dataIndex:'code',width:100},
    {header:'名称',dataIndex:'name',width:100},
    {header:'其它',dataIndex:'other',width:100}

    ],
    tbar:[{
        text:'增加'
        //iconCls:'tool-add'
    },'-',{
        text:'修改'
        //iconCls:'tool-edit'
        // iconCls:'tool-edit',
        // handler:this.editItem.createDelegate(this)
    },'-',{
        text:'删除'
        //iconCls:'tool-cut'
        // iconCls:'tool-cut',
        // handler:this.destroyItem.createDelegate(this)
    },'-',{
        text:'查询'
        //iconCls:'tool-find',
        //handler:this.showQueryWindow.createDelegate(this)
    },'-',{
        text:'导出到excel'
        //iconCls:'tool-find',
        //handler:this.onPrint.createDelegate(this)
    }],
        bbar:new Ext.PagingToolbar({
        store:ds,
        pageSize:this.pageSize
    }),
    border:false
    });
    panels = new Ext.Panel({
        border:     false,
        height:     200,
        width:      200,
        items:      grid
    });
    

    }
    Ext.onReady(function(){
    createPanel();
    createLayout();
    });
    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题