文章出處
文章列表
做后臺管理系統時遇到的問題,關于tab關閉后再打開不顯示,或者報錯
我在新的tabpanel中加入了一個grid,當我關閉再次打開就會報錯Cannot read property 'addCls' of null,
原因是我在定義grid的錯誤
這是錯誤代碼:
- Ext.define('HT.view.Grid',{
- extend:'Ext.grid.Panel',
- title : '人員列表',
- width:400,
- height:170,
- frame:true,
- store: {
- fields: ['id','name','sex','age','birthday'],
- proxy: {
- type: 'ajax',
- url : 'users',
- reader: {
- type: 'json',//Ext.data.reader.Json解析器
- root: 'users'
- }
- },
- autoLoad: true
- },
- columns: [//配置表格列
- new Ext.grid.RowNumberer(),//表格行號組件
- {header: "編號", width: 80, dataIndex: 'id', sortable: true},
- {header: "姓名", width: 80, dataIndex: 'name', sortable: true},
- {header: "年齡", width: 80, dataIndex: 'age', sortable: true},
- {header: "性別", width: 80, dataIndex: 'sex', sortable: true},
- {header: "生日", width: 80, dataIndex: 'birthdate', sortable: true}
- ]
- });
應該改為這個:
- Ext.define('HT.view.Grid',{
- extend:'Ext.grid.Panel',
- title : '人員列表',
- initComponent:function(){
- Ext.apply(this,{
- width:400,
- height:170,
- frame:true,
- store: {
- fields: ['id','name','sex','age','birthday'],
- proxy: {
- type: 'ajax',
- url : 'users',
- reader: {
- type: 'json',//Ext.data.reader.Json解析器
- root: 'users'
- }
- },
- autoLoad: true
- },
- columns: [//配置表格列
- new Ext.grid.RowNumberer(),//表格行號組件
- {header: "編號", width: 80, dataIndex: 'id', sortable: true},
- {header: "姓名", width: 80, dataIndex: 'name', sortable: true},
- {header: "年齡", width: 80, dataIndex: 'age', sortable: true},
- {header: "性別", width: 80, dataIndex: 'sex', sortable: true},
- {header: "生日", width: 80, dataIndex: 'birthdate', sortable: true}
- ]
- }),
- this.callParent(arguments);
- }
- });
看樣子屬性的設置都要用apply方法設置進去,nnd,這個問題整了兩天,終于解決了
文章列表
全站熱搜