contextmenu访问不到类中对象 急,大家帮帮忙

afgghepss8 2008-09-19 12:59:52
1. AdminCustomer=function()
2. {
3. this.editCustomerTypeWindow=new Ext.Window
4. (
5. {
6. title:'添加修改客户信息',
7. border:false,
8. width:700,
9. buttonAlign : 'center',
10. height:250,
11. autoScroll:true,
12. layout:'border',
13. renderTo:Ext.getBody(),
14. closeAction:'hide',
15. style:"text-align:center",
16. modal:true,
17. closable:true,
18. items:
19. new Ext.FormPanel
20. (
21. {
22. layout:'form',region:'center',id:'editcustomertypepanel',
23. items:
24. [
25. {
26. xtype:'treecombo',
27. value:'国内客户',
28. fieldLabel:'客户类型',
29. id:'CustomerTypeID',
30. width:180,
31. tree:new Ext.tree.TreePanel
32. (
33. {
34. animate:true,
35. border:false,
36. bodyborder:false,
37. collapsible:true,
38. frame:false,
39. enableDD:true,
40. enableDrag:true,
41. rootVisible:true,
42. autoScroll:true,
43. autoHeight:false,
44. lines:true,
45. root:new Ext.tree.AsyncTreeNode({id:'root',text:'客户类型',expanded:true,loader:this.treeloader,rootVisible:false})
46. }
47. )
48. }
49. ]
50. }
51. ),
52. bbar:[{text:' 保 存 '},{text:' 取 消 '}]
53. }
54. );
55. this.mytree=new Ext.tree.TreePanel
56. (
57. {
58. animate:true,
59. border:false,
60. bodyborder:false,
61. region:'west',
62. title:'客户类型',
63. collapsible:true,
64. frame:false,
65. enableDD:true,
66. autoScroll:true,
67. autoHeight:false,
68. width:200,
69. lines:true,
70. root:new Ext.tree.AsyncTreeNode({id:'root',text:'客户类型',expanded:true,loader:this.treeloader,rootVisible:false}),
71. listeners:
72. {
73. "contextmenu":function(node,e)
74. {
75. var nodemenu=new Ext.menu.Menu
76. ({
77. items:[
78. {text:'添加小类别',iconCls:'add',id:'add'},
79. {text:'编辑类别',iconCls:'leaf',handler:function(){alert(this.editCustomerTypeWindow)},scope:this},
80. {text:'删除类别',iconCls:'remove',handler:function(){}}
81. ]
82. });
83. nodemenu.showAt(e.getPoint());
84. }
85. }
86. }
87. );
88. }
contextmenu访问不到类中对象



这个this.editCustomerTypeWindow老是找不到,总是为undefine,请高手们解答,谢谢,如何才能访问到,谢谢
...全文
65 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
闭包没处理好

这样试试

AdminCustomer=function()
2. {
var PackUp=this;//闭包对象
3. this.editCustomerTypeWindow=new Ext.Window
4. (
5. {
6. title:'添加修改客户信息',
7. border:false,
8. width:700,
9. buttonAlign : 'center',
10. height:250,
11. autoScroll:true,
12. layout:'border',
13. renderTo:Ext.getBody(),
14. closeAction:'hide',
15. style:"text-align:center",
16. modal:true,
17. closable:true,
18. items:
19. new Ext.FormPanel
20. (
21. {
22. layout:'form',region:'center',id:'editcustomertypepanel',
23. items:
24. [
25. {
26. xtype:'treecombo',
27. value:'国内客户',
28. fieldLabel:'客户类型',
29. id:'CustomerTypeID',
30. width:180,
31. tree:new Ext.tree.TreePanel
32. (
33. {
34. animate:true,
35. border:false,
36. bodyborder:false,
37. collapsible:true,
38. frame:false,
39. enableDD:true,
40. enableDrag:true,
41. rootVisible:true,
42. autoScroll:true,
43. autoHeight:false,
44. lines:true,
45. root:new Ext.tree.AsyncTreeNode({id:'root',text:'客户类型',expanded:true,loader:this.treeloader,rootVisible:false})
46. }
47. )
48. }
49. ]
50. }
51. ),
52. bbar:[{text:' 保 存 '},{text:' 取 消 '}]
53. }
54. );
55. this.mytree=new Ext.tree.TreePanel
56. (
57. {
58. animate:true,
59. border:false,
60. bodyborder:false,
61. region:'west',
62. title:'客户类型',
63. collapsible:true,
64. frame:false,
65. enableDD:true,
66. autoScroll:true,
67. autoHeight:false,
68. width:200,
69. lines:true,
70. root:new Ext.tree.AsyncTreeNode({id:'root',text:'客户类型',expanded:true,loader:this.treeloader,rootVisible:false}),
71. listeners:
72. {
73. "contextmenu":function(node,e)
74. {
75. var nodemenu=new Ext.menu.Menu
76. ({
77. items:[
78. {text:'添加小类别',iconCls:'add',id:'add'},
79. {text:'编辑类别',iconCls:'leaf',handler:function(){alert(PackUp.editCustomerTypeWindow)},scope:this},
80. {text:'删除类别',iconCls:'remove',handler:function(){}}
81. ]
82. });
83. nodemenu.showAt(e.getPoint());
84. }
85. }
86. }
87. );
88. }

52,782

社区成员

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

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