Extjs:无法读取undefined的属性'substring'

时间:2016-02-17 09:54:23

标签: javascript extjs

您好我想在Extjs 4.1.1中添加网格面板到我的视图,但是我在浏览器控制台“无法读取未定义的属性'子字符串'时收到此错误”。这是我的js代码:

Ext.require([
                  '*'
              ]);
     Ext.onReady(function(){

            Ext.tip.QuickTipManager.init();
            Ext.create('Ext.data.Store', {
                storeId:'simpsonsStore',
                fields:['name', 'email', 'phone'],
                data:{'items':[
                    { 'name': 'Lisa',  "email":"lisa@simpsons.com",  "phone":"555-111-1224"  },
                    { 'name': 'Bart',  "email":"bart@simpsons.com",  "phone":"555-222-1234" },
                    { 'name': 'Homer', "email":"home@simpsons.com",  "phone":"555-222-1244"  },
                    { 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254"  }
                ]},
                proxy: {
                    type: 'memory',
                    reader: {
                        type: 'json',
                        root: 'items'
                    }
                }
            });

            Ext.create('Ext.grid.Panel', {
                title: 'Simpsons',
                store: Ext.data.StoreManager.lookup('simpsonsStore'),
                columns: [
                    { text: 'Name',  dataIndex: 'name' },
                    { text: 'Email', dataIndex: 'email', flex: 1 },
                    { text: 'Phone', dataIndex: 'phone' }
                ],
                height: 200,
                width: 400,
                renderTo:  Ext.Element.get('test')
            });

        });

这是html代码:

   <div id="test"> </div>

1 个答案:

答案 0 :(得分:1)

按ID获取元素的正确方法是:Ext.get("my-div"); http://www.objis.com/formationextjs/lib/extjs-4.0.0/docs/api/Ext.core.Element.html

所以我认为您需要将renderTo: Ext.Element.get('test')更改为:renderTo: Ext.get('test')