<html>
<head>
<!-- Ext按钮Demo -->
<script src="js/ext-all.js"></script>
<link href="css/ext-theme-gray-all.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
Ext.onReady(function() {
Ext.create('Ext.Button', {
text : 'Click me',
arrowAlign : 'right',/*menu显示的按钮位置(bottom/right) */
renderTo : Ext.DomQuery.selectNode("div[@id='as']"),
handler : function() {/* 单击后的处理事件 */
if (this.clickCount) {
this.clickCount++;
// alert('You have clicked the button "' + this.clickCount + '" times.\n\nTry clicking it again..');
} else {
this.clickCount = 1;
// alert('You just clicked the button for the first time!\n\nTry pressing it again..');
}
},
enableToggle : true,/*点击会改变按钮显示状态(类似于开关) */
menu : [/* 单击后展开的菜单 */
{//按钮菜单
text : 'Item 1',
href : 'http://www.baidu.com',
hrefTarget : '_blank'
}, {
text : 'Item 2'
}, {
text : 'Item 3'
}, {
text : 'Item 4'
} ],
listeners : {/*监听触发事件并处理 */
click : function() {
// this == the button
this.setText('I was clicked!');
},
mouseover : function() {
// set a new config which says we moused over, if not already set
if (!this.mousedOver) {
this.mousedOver = true;
// alert('You moused over a button!\n\nI wont do this again.');
}
}
}
});
Ext.create('Ext.Button', {
text : 'Load',
renderTo : Ext.DomQuery.selectNode("div[@id='load']"),
menu : [//类型菜单
{
xtype : 'textfield',
fieldLabel : 'Foo'
}, {
xtype : 'textfield',
fieldLabel : 'Bar'
}, {
xtype : 'numberfield',
fieldLabel : 'Num'
} ]
});
Ext.create('Ext.button.Cycle', {//循环菜单
showText : true,
prependText : 'View as ',
renderTo : Ext.DomQuery.selectNode("div[@id='Cycle']"),
menu : {
id : 'view-type-menu',
items : [ {
text : 'Java',
iconCls : 'view-text',
checked : true
}, {
text : 'C#',
iconCls : 'view-html'
}, {
text : 'Object C',
iconCls : 'view-html'
}]
},
changeHandler : function(cycleBtn, activeItem) {
Ext.Msg.alert('Change View', activeItem.text);
}
});
});
</script>
</head>
<body>
<div id="as" style="margin-left: 100px;"></div>
<br>
<div id="load" style="margin-left: 100px;"></div>
<br>
<div id="Cycle" style="margin-left: 100px;"></div>
</body>
</html>
Ext学习笔记(3):Button学习Demo
最新推荐文章于 2017-10-17 21:35:12 发布