extjs中Toolbar工具栏
类别:Web前端 浏览量:12580
时间:2013-10-13 extjs中Toolbar工具栏
extjs中Toolbar工具栏extjs中Ext.toolbar.Toolbar可以用来放置一些工具类操控按钮和菜单,工具栏控件可以被附加在面板、窗口等容器类控件中,可以在四个方位添加多个工具栏控件。下面分别介绍几个实例,来对extjs中的工具栏有一定的认识。
简单工具栏:
<script type="text/javascript">
Ext.onReady(function() {
var toolbar = new Ext.toolbar.Toolbar({
renderTo:Ext.getBody(),
width:500
});
toolbar.add(
{text:'新建'},{text:'打开'},
{text:'编辑'},{text:'保存'},//加入按钮
'-',
{//加入表单元素
xtype:'textfield',
hideLabel:true,
width:150
},
'->',
'<a href=#>超链接</a>',
{xtype:'tbspacer',width:50},
'静态文本'
);
});
</script>
效果图:
Ext.toolbar.Toolbar的overflowHandler属性实例:
如果工具栏上的item项目过多,而面板的长度不够那会怎么样?我们需要设置 overflowHandler: 'Menu',代码如下:
效果图:
在右侧的工具栏
var panel = new Ext.Panel({
renderTo: "li1",
width: 600,
height: 250,
collapsible: true,
layout: 'fit',
title: '演示工具栏',
items: listView,
tbar: tbar,
bbar: bbar,
rbar: [{
iconCls: 'add16',
tooltip: '按钮1'
},
'-',
{
iconCls: 'add16',
tooltip: {
text: '按钮2',
anchor: 'left'
}
}, {
iconCls: 'add16'
}, {
iconCls: 'add16'
},
'-',
{
iconCls: 'add16'
}
]
});
效果图
动态工具栏添加项:
//创建母工具栏
var toolbar = Ext.create('Ext.toolbar.Toolbar', {
renderTo: document.body,
width: 700,
items:
[
{
text: 'Example Button'
}
]
});
var addedItems = []; //添加项数组
Ext.create('Ext.toolbar.Toolbar', {
renderTo: document.body,
width: 700,
margin: '5 0 0 0',
items:
[
{
text: 'Add a button',
scope: this,
handler: function () {
var text = prompt('Please enter the text for your button:');
addedItems.push(toolbar.add({ //装入
text: text
}));
}
},
{
text: 'Add a text item',
scope: this,
handler: function () {
var text = prompt('Please enter the text for your item:');
addedItems.push(toolbar.add(text));
}
},
{
text: 'Add a toolbar seperator',
scope: this,
handler: function () {
addedItems.push(toolbar.add('-'));
}
},
{
text: 'Add a toolbar spacer',
scope: this,
handler: function () {
addedItems.push(toolbar.add('->'));
}
},
'->',
{
text: 'Remove last inserted item',
scope: this,
handler: function () {
if (addedItems.length) {
toolbar.remove(addedItems.pop());
} else if (toolbar.items.length) {
toolbar.remove(toolbar.items.last());
} else {
alert('No items in the toolbar');
}
}
},
{
text: 'Remove all items',
scope: this,
handler: function () {
toolbar.removeAll();
}
}
]
});
效果图:
您可能感兴趣
- extjs中treegrid
- ExtJs 中Viewport 的使用
- extjs中treepanel例子
- extjs实现树形下拉框
- extjs checkboxGroup 复选框的用法
- Extjs中FieldSet的收缩和展开
- extjs Border边框布局
- extjs card卡片式布局
- extjs table布局
- Extjs中grid 的ColumnModel 属性配置
- ExtJs常用代码片段
- Extjs menu菜单的简单用法
- extjs radiogroup赋值和取值
- ExtJs中怎么上传文件
- extjs xtype的使用
- Extjs中文乱码
- 演员陈创,火于 哮天犬 ,颠峰于 福贵 ,现状却令人唏嘘(演员陈创火于哮天犬)
- 幼小衔接-20以内看图读数 写数 数的组成练习题(幼小衔接-20以内看图读数)
- 你只要花上20天记单词,英语成绩就能从57提到100(你只要花上20天记单词)
- 夕云天际飞,亢龙化太极(夕云天际飞亢龙化太极)
- 爱情可以当饭吃吗(怎么回复)
- 高考数学题(高考数学题基础题占多少分)
热门推荐
- dedecms分页效果(dedecms重新定义cn_substr函数截取字数更准确)
- css空白边叠加
- Visual Studio 编译中活动平台AnyCPU
- python编写小程序实现密码验证(python实现扫描ip地址的小程序)
- wdc真正的底层公链(LiteSpeed服务器用htaccess的防盗链代码)
- mysql千万数据如何优化(MySQL千万级数据的表如何优化)
- php如何继承多个类(PHP面向对象程序设计子类扩展父类子类重新载入父类操作详解)
- python中的insert(python assert的用处示例详解)
- laravel提交数据时间(laravel实现查询最后执行的一条sql语句的方法)
- mysql子查询用法(MySQL 子查询和分组查询)