“Uncaught TypeError: Cannot call method 'createChild' of undefined" 问题的解决

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);
}

 

以上!

posted @ 2013-07-05 22:20  尼玛范爷  阅读(5502)  评论(0编辑  收藏  举报