English 中文(简体)
extjs gridpanel: 当GridPanel窗再次显示时,Column Model就变得无效。
原标题:extjs gridpanel: ColumnModel becomes null when GridPanel window shows again

我用预先配置的Column Model和仓库界定了GridPanel,并将这一GridPanel置于Ext.Window中;然而,如果我关闭并再次显示,GridPanel的Column Model倒台,那么该GridPanel无法正确提供。

www.un.org/Depts/DGACM/index_french.htm

 var stSummary = new Ext.data.JsonStore({ //define the store for Summary_Grid
        fields : [
        {
            name:  recID 
        }, {
            name :  name ,
        }],
        data: []
    });

var colModelSummary = { //define the ColumnModel for Summary_Grid
    columns:
    [
        {
            header : "ID",
            width : 50,
            sortable : true,
            menuDisabled: true,
            dataIndex :  recID 
        },
        {
            header : "Name",
            width : 100,
            sortable : true,
            menuDisabled: true,
            dataIndex :  name 
        }
    ]
};

var reportConfig = {
    id :  Report_Window ,
    width : 250,
    floating : true,
    style : {
        opacity : 0.7,
    },
    title : "Report",
    layout:  fit ,
    items : [{
        xtype:  tabpanel ,
        id:  Report_Tab ,
        height: 200,
        activeTab: 1,
        items: 
        [
            {
                xtype :  grid ,
                store : stSummary,
                colModel : new Ext.grid.ColumnModel(colModelSummary),
                stripeRows : true,
                id : "Summary_Grid",
                title : "Summary at",
                sm : new Ext.grid.RowSelectionModel({
                    singleSelect : true
                }),
                listeners: {
                     beforerender : function() {
                        console.log(this.getColumnModel().getColumnCount());
                    }
                }
            }, 
            {
                xtype :  form ,
                id :  Report_Form ,
                title:  Item Report ,
                frame : true,
                labelAlign :  left ,
                bodyStyle :  padding:2px ,
                autoScroll: true,
                layout :  column ,
                items : []  
            }
        ]
    }],
    resizable : {
        dynamic : true
    }
};
var reportWindow = new Ext.Window(reportConfig);

reportWindow.show();

document.onclick = myClickHandler;


    function myClickHandler() {
      if(!Ext.getCmp( Report_Window )) {
        var reportWindow = new Ext.Window(reportConfig);
      }

      Ext.getCmp( Report_Window ).show();
    }
});

和错误:

Uncaught TypeError: Cannot read property  length  of undefined
Ext.grid.ColumnModel.Ext.extend.getColumnCount                  ext-all.js:11
最佳回答

我实际上只是抄录了你的法典。 我在结尾处添加了Window.show()的报告——它起作用! 你们能否展示所有法典?

Please note that it might be a close/hide problem, do you recreate your window each time?

EDIT:

制作<条码>cl:隐藏在你的窗口配置上。

Check this for details:

<><>><>>>>

我再次测试你的法典,并再次工作! 我只纠正了像外衣一样的几件事——我的哈尔伯建议了。 之后,我把它放入了Ext.onReady——它起作用! Ext.version = 3.2.1

Check the whole code:

Ext.onReady(function() {
    var stSummary = new Ext.data.JsonStore({
//define the store for Summary_Grid
            fields: [
                {
                    name:  recID 
                }, {
                    name:  name 
                }],
            data: []
        });

    var colModelSummary = {
//define the ColumnModel for Summary_Grid
        columns:
            [
                {
                    header: "ID",
                    width: 50,
                    sortable: true,
                    menuDisabled: true,
                    dataIndex:  recID 
                },
                {
                    header: "Name",
                    width: 100,
                    sortable: true,
                    menuDisabled: true,
                    dataIndex:  name 
                }
            ]
    };

    var reportConfig = {
        id:  Report_Window ,
        width: 250,
        floating: true,
        style: {
            opacity: 0.7
        },
        title: "Report",
        layout:  fit ,
        items: [{
            xtype:  tabpanel ,
            id:  Report_Tab ,
            height: 200,
            activeTab: 1,
            items:
                [
                    {
                        xtype:  grid ,
                        store: stSummary,
                        colModel: new Ext.grid.ColumnModel(colModelSummary),
                        stripeRows: true,
                        id: "Summary_Grid",
                        title: "Summary at",
                        sm: new Ext.grid.RowSelectionModel({
                            singleSelect: true
                        }),
                        listeners: {
                             beforerender : function() {
                                console.log(this.getColumnModel().getColumnCount());
                            }
                        }
                    },
                    {
                        xtype:  form ,
                        id:  Report_Form ,
                        title:  Item Report ,
                        frame: true,
                        labelAlign:  left ,
                        bodyStyle:  padding:2px ,
                        autoScroll: true,
                        layout:  column ,
                        items: []
                    }
                ]
        }],
        resizable: {
            dynamic: true
        }
    };
    var reportWindow = new Ext.Window(reportConfig);

    reportWindow.show();

    document.onclick = myClickHandler;


    function myClickHandler() {
        if (!Ext.getCmp( Report_Window )) {
            reportWindow = new Ext.Window(reportConfig);
        }

        Ext.getCmp( Report_Window ).show();
    }
});
问题回答

暂无回答




相关问题
ExtJS load form items/fields from database

I am using ExtJS 3 here. I would like to populate a formpanel from database with fields to be submitted. Basically, I don t know witch fields my form will have and I want to generate all formpanel ...

How to use Ext JS for role based application

I am planning to use Ext JS for a large application. The application s features are role based. When user login, they only see menu and screen features related to them. My server side technology will ...

Dynamically adding a TabPanel to a Panel Region

I have a Panel layout with a TreePanel in one region. A user clicks on an node in the tree and a TabPanel should be displayed in another region with information, editing tools etc. for that tree node....

How to embed Json result within Extjs Panel?

I have some issues with Json result and embed it within the html of the Extjs Panel. Here s that I have managed to get so far. myPanel is embedded within a mainPanel, and I have some shows/hide of ...

Ajax data update. Extjs

I need to keep certain data ( in a grid) up to date and was gonna do a poll to the server every 15 seocnds or so to get the data and refresh the grid, however it feels a bit dirty ( the grid will have ...

Better way to call superclass method in ExtJS

All the ExtJS documentation and examples I have read suggest calling superclass methods like this: MyApp.MyPanel = Ext.extend(Ext.Panel, { initComponent: function() { // do something MyPanel ...

Merged Headers in Ext JS Grid

Is it possible to have two headers in Ext JS grids? I have to show my grid as grouped data.. for example product types and products. In my case I need a grid like this: Field | Product Type A ...

热门标签