Ext.view.View使用TPL问题

shw586 2013-12-26 12:13:56
代码如下:
{
/// <reference path="../../ext/ext-all.js" />
Ext.define('User', {
extend: 'Ext.data.Model',
fields: ["name", "title"],
hasMany: [{ model: 'User', name: 'childrens' }]
});

var myStore = Ext.create('Ext.data.Store', {
model: 'User',
proxy: {
type: 'ajax',
url: 'user.txt',
reader: {
type: 'json',
root: 'users'
}
},
autoLoad: true
});

Ext.create('Ext.view.View', {
width:200,
store: myStore,
tpl: ['<div>',
'<tpl for=".">',
'<div>',
'<div class="nrm_menu_banner">{name}</div>',
'<tpl for="childrens">',
'<div class="nrm_menu_content">{name}</div>',
'</tpl>',
'</div>',
'</tpl>',
'</div>'
],
itemSelector: 'div.nrm_menu_content',
overItemCls: 'hover',
trackOver: true,
renderTo: Ext.getBody()
});
}
现在遇到的问题是,如果itemSelector设置为 'div.nrm_menu_content',则报
Uncaught TypeError: Cannot read property 'internalId' of undefined错误,why???
...全文
313 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
shw586 2013-12-26
  • 打赏
  • 举报
回复
user.txt内容: { users: [{ name: "系统管理", title: "systemManager", childrens:[ {name:"系统设置",title:"systemSetup"}, {name:"用户管理",title:"userManager"} ] }, { name: "虚拟资源管理", tag: "visualRes", childrens:[ {name:"系统设置1",title:"myd"}, {name:"用户管理1",title:"demo1"} ] } ] }
  • 打赏
  • 举报
回复
itemSelector : StringREQUIRED4 This is a required setting. A simple CSS selector (e.g. div.some-class or span:first-child) that will be used to determine what nodes this DataView will be working with. The itemSelector is used to map DOM nodes to records. As such, there should only be one root level element that matches the selector for each record.

87,988

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧