嗨,我想在Extjs4.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>
发布于 2016-02-18 07:07:50
通过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')
https://stackoverflow.com/questions/35453232
复制相似问题