Uncaught TypeError: Cannot call method 'createChild' of undefined
我在使用Ext 4.1.1做grid.Panel,然后chrome爆出這么個錯誤,無法理解,百度谷歌終於改好了
是這樣子的,grid.Panel的整個代碼要放到Ext.onReady里面,例如
Ext.onReady(function(){ searchProcess(); });
searchProcess()方法里面寫了grid.Panel的全部代碼。
貼一下吧,功能不全,呵呵
Ext.Loader.setConfig({enabled:true});
Ext.Loader.setPath('Ext.ux', basePath + 'javascript/extjs/ux');
Ext.BLANK_IMAGE_URL=basePath + "images/s.gif";
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.state.*',
'Ext.ux.grid.FiltersFeature',
'Ext.toolbar.Paging',
'Ext.ux.ajax.JsonSimlet',
'Ext.ux.ajax.SimManager'
]);
Ext.define('processRejectDevice', {
extend:'Ext.data.Model',
fields:[
{ name:'id', type:'int', mapping:'id', convert:null, defaultValue:undefined},
{ name:'userId', type:'string', convert:null, defaultValue:undefined},
{ name:'finished', type:'string', convert:null, defaultValue:undefined},
{ name:'processType', type:'string', convert:null, defaultValue:undefined},
{ name:'destination', type:'string', convert:null, defaultValue:undefined},
{ name:'initDate', type:'string', convert:null, defaultValue:undefined},
{ name:'reason', type:'string', convert:null, defaultValue:undefined},
{ name:'title', type:'string', convert:null, defaultValue:undefined}
],
idProperty:'id'
});
var searchProcess = function () {
Ext.QuickTips.init();
Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));
var store = Ext.create('Ext.data.Store', {
model:'processRejectDevice',
remoteSort:true,
proxy:{
//異步獲取數據,這里的URL可以改為任何動態頁面,只要返回JSON數據即可
type:'ajax',
url:'./processSecFile_getProcessByFileid4Ajax.action',
reader:{
root:'items',
totalProperty:'total'
}
},
pageSize:20
});
store.on('beforeload', function (store, options) {
var new_params = {fileid:fileId};
Ext.apply(store.proxy.extraParams, new_params);
});
//分頁組件
var pagingToolbar = new Ext.PagingToolbar({
emptyMsg:"沒有數據",
displayInfo:true,
displayMsg:"顯示從{0}條數據到{1}條數據,共{2}條數據",
store:store
});
var sm = Ext.create('Ext.selection.CheckboxModel');
var grid = Ext.create('Ext.grid.Panel', {
store:store,
stateful:true,
//collapsible: true,
multiSelect:true,
stateId:'stateGrid',
bbar:pagingToolbar,
selModel:sm,
columns:[
{dataIndex:'id', text:'流程id', width:30, filterable:true, sortable:true },
{dataIndex:'userId', text:'用id', width:100, filterable:true, sortable:true },
{dataIndex:'finished', text:'是否', width:100, sortable:true, filterable:true},
{dataIndex:'processType', text:'流程類型', width:50, sortable:true, filterable:true},
{dataIndex:'destination', text:'destination', width:50, sortable:true, filterable:true},
{dataIndex:'initDate', text:'發起日期', width:50, sortable:true, filterable:true},
{dataIndex:'reason', text:'發起原因', width:100, sortable:true, filterable:true},
{dataIndex:'title', text:'標題', width:50, sortable:true, filterable:true}
],
height:400,
bodyStyle:'width:100%',
renderTo:Ext.getBody(),
forceFit:true,
viewConfig:{
stripeRows:true,
enableTextSelection:true
}
});
store.loadPage(1);
}
以上!
