ext中对panel增加html元素后,ext.get(id)取得null值

fly2749 2010-12-01 05:43:55
仿照之前一个contentpanel自己单独创建了一个panel对象,
之前的代码:

var contentTabPanel=new Ext.TabPanel({
style:"padding:0 0px 0 0px",
region:'center',
border: false,
enableTabScroll:true,
id:"ContentTabPanel",
activeTab:0,
autoScroll: true,
scrollIncrement : 350,
scrollRepeatInterval : 350,
height:'100%',
layoutOnTabChange:true,
deferredRender:false //加载时渲染所有
});




之后的代码与当前代码一样建立,只是变量名不同。
然后再方法中调用:

var east_south_panel=Ext.getCmp("East_south_panel");
alert(parent.Ext.get(iframeID));
east_south_panel.add({html:'<iframe name="'+iframeID+'" id="'+iframeID+'" scrolling="'+scrolling+'" frameborder="0" border="0" width="100%" height="100%" src="'+Form_ContextPath+iframeURL+'"> </iframe>'}).show();
alert(parent.Ext.get(iframeID));


第一个alert为空正确,因为还没有增加属性,但是第二个alert中确得到的还是null。
而使用之前的contentTabPanel在第一次得到的也是null,但是在赋了值后,可以得到对象,并显示object,请各位帮分析下原因,上面的那段代码为什么在add后,alert出的还是null???谢谢
...全文
1500 59 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
59 条回复
切换为时间正序
请发表友善的回复…
发表回复
fly2749 2010-12-03
  • 打赏
  • 举报
回复
[Quote=引用 40 楼 asdujiayong 的回复:]

put tabPanel into a formPanel ?
it's so ...
why do you do so?
[/Quote]
因为我要在一个formpanel中实现一个列表,要求是这样的,上面会有相应的按钮,和查询条件
asdujiayong 2010-12-03
  • 打赏
  • 举报
回复
[Quote=引用 38 楼 flyerwing 的回复:]
I Know,but write Ext.getCmp("id"),it can not find it still after call doLayout,why?
[/Quote]
if you call document.getElementById('XX') method ,how about the result?
asdujiayong 2010-12-03
  • 打赏
  • 举报
回复
[Quote=引用 39 楼 smh821025 的回复:]
我新增了 renderTo:Ext.getBody(),可以获得值了,
现在有一个布局问题:
我想把它放在一个FormPanel里,直接把变量写在这里为何不行?

JScript code

..................
..................
width:90
}
……
[/Quote]
put tabPanel into a formPanel ?
it's so ...
why do you do so?
fly2749 2010-12-03
  • 打赏
  • 举报
回复
我新增了 renderTo:Ext.getBody(),可以获得值了,
现在有一个布局问题:
我想把它放在一个FormPanel里,直接把变量写在这里为何不行?
		
..................
..................
width:90
}
]
},

east_south_panel //刚猜得到的tablepanel对象的变量

]
flyerwing 2010-12-03
  • 打赏
  • 举报
回复
I Know,but write Ext.getCmp("id"),it can not find it still after call doLayout,why?
asdujiayong 2010-12-03
  • 打赏
  • 举报
回复
[Quote=引用 36 楼 flyerwing 的回复:]
var b = new Ext.Panel({ title: "子容器", html: '<iframe name="iframeID" id="iframeID" scrolling="auto" frameborder="0" border="0" width="100%" height="100%" src="http://www.qq.com"> </iframe>' });
east_……
[/Quote]
that is why we should call doLayout method after we add a new component .
flyerwing 2010-12-03
  • 打赏
  • 举报
回复
var b = new Ext.Panel({ title: "子容器", html: '<iframe name="iframeID" id="iframeID" scrolling="auto" frameborder="0" border="0" width="100%" height="100%" src="http://www.qq.com"> </iframe>' });
east_south_panel.add(b);
east_south_panel.doLayout(true);
alert(document.getElementById("iframeID"));
==================================================
偶刚用这个试了下,找到了HTMLOBJECT.
如果不调用doLayout就找不到
fly2749 2010-12-03
  • 打赏
  • 举报
回复
[Quote=引用 34 楼 asdujiayong 的回复:]

引用 31 楼 smh821025 的回复:
引用 30 楼 asdujiayong 的回复:

readOnly means add ,remove and modify operation are not allowed.

我试着调用了renderTo属性,并指定了值为iframeID,也就是html中的id值。
也还是会进入ext-all.js文件中报空。
之前没有add ……
[/Quote]
我引用的是html中的ID,它适用于iframe 么,我使用的不是div,应该是一样的吧
32试过,无效
asdujiayong 2010-12-03
  • 打赏
  • 举报
回复
[Quote=引用 31 楼 smh821025 的回复:]
引用 30 楼 asdujiayong 的回复:

readOnly means add ,remove and modify operation are not allowed.

我试着调用了renderTo属性,并指定了值为iframeID,也就是html中的id值。
也还是会进入ext-all.js文件中报空。
之前没有add renderTo属性时,在下面alert出的值为n……
[/Quote]
if you want to add renderTo property,like renderTo: 'tabPanel', there should be div that it's id is 'tabpanel' in your displaying page.
and you can try to do just like 32f.
fly2749 2010-12-03
  • 打赏
  • 举报
回复
[Quote=引用 32 楼 flyerwing 的回复:]

var east_south_panel=Ext.getCmp("East_south_panel");
alert(parent.Ext.get(iframeID));
east_south_panel.add({html:'<iframe name="'+iframeID+'" id="'+iframeID+'" scrolling="'+scrolling+'" frameborde……
[/Quote]
没什么意义
flyerwing 2010-12-03
  • 打赏
  • 举报
回复
var east_south_panel=Ext.getCmp("East_south_panel");
alert(parent.Ext.get(iframeID));
east_south_panel.add({html:'<iframe name="'+iframeID+'" id="'+iframeID+'" scrolling="'+scrolling+'" frameborder="0" border="0" width="100%" height="100%" src="'+Form_ContextPath+iframeURL+'"> </iframe>'}).show();
east_south_panel.doLayout(true);
alert(parent.Ext.get(iframeID));
这样不知道成不成.
fly2749 2010-12-03
  • 打赏
  • 举报
回复
[Quote=引用 30 楼 asdujiayong 的回复:]

readOnly means add ,remove and modify operation are not allowed.
[/Quote]
我试着调用了renderTo属性,并指定了值为iframeID,也就是html中的id值。
也还是会进入ext-all.js文件中报空。
之前没有add renderTo属性时,在下面alert出的值为null,是不是因为没有增加renderTo的问题?
如果没有增加renderTo属性,是不是指html那行没有编译?
asdujiayong 2010-12-03
  • 打赏
  • 举报
回复
readOnly means add ,remove and modify operation are not allowed.

asdujiayong 2010-12-03
  • 打赏
  • 举报
回复
readOnly means add ,remove and modify operation is not allowed.
fly2749 2010-12-03
  • 打赏
  • 举报
回复
[Quote=引用 58 楼 asdujiayong 的回复:]

引用 57 楼 flyerwing 的回复:

洋鬼子大哥VERY GOOD!
嘿嘿.

哥们,偶纯的中国人...
只是公司电脑没有汉语输入法...
没办法才...
[/Quote]
oh,my god。因为你为了练e文呢
asdujiayong 2010-12-03
  • 打赏
  • 举报
回复
[Quote=引用 57 楼 flyerwing 的回复:]

洋鬼子大哥VERY GOOD!
嘿嘿.
[/Quote]
哥们,偶纯的中国人...
只是公司电脑没有汉语输入法...
没办法才...
flyerwing 2010-12-03
  • 打赏
  • 举报
回复
洋鬼子大哥VERY GOOD!
嘿嘿.
flyerwing 2010-12-03
  • 打赏
  • 举报
回复
var fpanel=new Ext.fromPanel({...});
var tapanel1=new Ext.TabPanel({.....,items[fpanel]});
...............
var mpnl=Ext.Panel({
....,
items[tapanel1,.....]
})
.............
写这鬼东西,顺序非常重要;有时
fly2749 2010-12-03
  • 打赏
  • 举报
回复
[Quote=引用 54 楼 asdujiayong 的回复:]

I've never heard this kind of fallacy.
at least ,I think it is good for you to try to debug you program...
[/Quote]
我的思路被推翻了,现在要重新实现,如何在同一个页面通过ext进行查询,并在当前页面显示
asdujiayong 2010-12-03
  • 打赏
  • 举报
回复
I've never heard this kind of fallacy.
at least ,I think it is good for you to try to debug you program...
加载更多回复(39)

52,792

社区成员

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

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