生活就是一本书,需要我们用心去读
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%![](https://www.cnblogs.com/Images/dot.gif)
2
/**
3
* @author lzb
4
* Created on 2008-12-18
5
* 练习使用Ext-menu
6
*
7
*/
8
%>
9![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
@ page contentType="text/html; charset=UTF-8" %>
10
<html>
11
<head>
12
<title>练习使用Ext-menu</title>
13
<!-- Ext css -->
14
<link rel="stylesheet" type="text/css" href="http://www.cnblogs.com/../resources/css/ext-all.css"/>
15
<link rel="stylesheet" type="text/css" href="http://www.cnblogs.com/examples.css"/>
16
<link rel="stylesheet" type="text/css" href="http://www.cnblogs.com/menu/menus.css" />
17
18
<!-- Ext js -->
19
<script type="text/javascript" src="http://www.cnblogs.com/../adapter/ext/ext-base.js"></script>
20
<script type="text/javascript" src="http://www.cnblogs.com/../ext-all.js"></script>
21
<script type="text/javascript" src="http://www.cnblogs.com/../source/locale/ext-lang-zh_CN.js"></script>
22
<script type="text/javascript" src="http://www.cnblogs.com/examples.js"></script>
23![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<script type="text/javascript">![](https://www.cnblogs.com/Images/dot.gif)
24
//action被禁用,所有引用到的action地方的功能都被禁用
25![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Ext.onReady(function()
{
26![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
var action = new Ext.Action(
{
27
text:'行为1',
28![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
handler:function ()
{
29
Ext.example.msg('click','你点击了行为1');
30
},
31
iconCls:'blist'
32
})
33![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
var panel= new Ext.Panel(
{
34
title:'所有行为',
35
width:500,
36
height:300,
37
borderStyles:'10px',
38
bbar:[
39
action
40![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
,
{
41
text:'text行为',
42
//这个地方的menu是个数组[]
43![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
menu:[action,
{text:'行为2',handler:function ()
{alert('Yesterday once more');},iconCls:'blist'}]
44
}],
45
items: [
46
new Ext.Button(action)
47
],
48
renderTo:Ext.getBody()
49
});
50
//getBottomToolbar()这是一个对象,记着()
51
//panel.getTopToolbar().add('',param1,param2
.)
52
//里面第一个参数:-〉这个分割符号,是右对齐;- 生成一个竖线
53![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
panel.getBottomToolbar().add('->',
{
54
text:'禁用',
55![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
handler:function ()
{
56
action.setDisabled(!action.isDisabled());
57
this.setText(action.isDisabled()?'激活':'禁用');
58
}
59![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
},
{
60
text:'修改图标',
61![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
handler:function()
{
62
action.setIconClass(action.getIconClass()=='blist'?'bmenu':'blist');
63
}
64![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
},
{
65
text:'修改标题',
66![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
handler:function ()
{
67
//Ext.Msg Msg大写
68![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Ext.Msg.prompt('新标题','请输入新标题',function(btn,text)
{
69![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
if(btn=='ok' && text)
{
70
action.setText(text);
71![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
action.setHandler(function ()
{
72
Ext.example.msg('msg','action1更换了方法');
73
});
74
}
75
});
76
}
77
});
78
});
79
</script>
80
</head>
81
<body>
82
83
</body>
84
</HTML>
85![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)