1.4.4. 工具条toolbar

<script type="text/javascript">
  $().ready(function() {
    $("#toolbar").toolbar({1
      toolbar : [ {2
        id : "transmit",
        name : "转发",
        className : "ico16",
        subMenu : [ {3
          name : "协同",
          click : function(){
             alert(111);
          }
        }, {
          name : "邮件",
          click : function(){
             alert(222);
          }
        } ]
      }, {
        id : "delete",
        name : "删除",
        iconClass : "ico16 del"
      }, {
        id : "refresh",
        name : "刷新",
        iconClass : "ico16 refresh"
      } ]
    });
  });
</script>

<div id="toolbar"></div>4

1

toobar函数初始化工具条,id指定某个div

2

设置toolbar参数,值为要显示的toolbar按钮数组

3

带菜单的用subMenu配置子集功能操作

4

要显示toolbar的div

toolbar组件初始化时,框架提供了根据资源权限和插件依赖来判定某些toolbar操作是否显示的支持,代码例子如下:

$("#toolbar").toolbar({
      toolbar : [ {
        resCode : "res1",1
        pluginId : "plugin1",2
        name : "转发",
        className : "ico16",
        subMenu : [ {
          resCode : "res2",3
          pluginId : "plugin2",4
          name : "协同",
          click : function() {
            alert("转发协同");
          }
        }, {
          resCode : "res2",
          pluginId : "plugin1",
          name : "邮件",
          click : function() {
             alert("转发邮件");
          }
        } ]
      }
    ]});

1

资源代码控制toolbar项是否显示,如果同时存在pluginId,则pluginId优先

2

插件依赖判断toolbar项是否显示

3

资源代码控制toolbar按钮是否显示,如果同时存在pluginId,则pluginId优先

4

插件依赖判断toolbar按钮是否显示

属性

属性 类型 描述
toolbar中按钮参数 例[删除]    
id string 唯一标记
name string 名称
click function 点击事件
className string 样式名称[按钮图标--从通用class中查询]
subMenu object 下拉菜单 : [{id:'submenu1',name: "协同",click: function(){ alert(1);}}, {id:'submenu2',name: "邮件",click: function(){alert(2);}}]
toolbar中添加select    
type string type:select
text string 默认select的值
value string 默认select的value
disable boolean 设置select置灰
onchange function select的onchange方法
items 数组 select的option选项:[{ text: '普通', value: '0' }, { text: '重要', value: '1' }, { text: '非常重要', value: '2' }]
className string 设置class:hidden时隐藏select
方法

方法 参数 描述
selected(id) 按钮id 设置某一个toolbar按钮高亮显示用 toolbar.selected(id)
unselected() 可有可无 1、设置某一个toolbar按钮不高亮显示: toolbar.unselected(id) 2、unselected(),不添加参数,所有按钮取消高亮显示
disabled(id) 按钮id 设置某一个toolbar按钮不可用 toolbar.disabled(id)
enabled(id) 按钮id 设置某一个toolbar可用 toolbar.enabled(id)
disabledAll() 所有toolbar按钮不可用 toolbar.disabledAll()
enabledAll() 所有toolbar按钮可用 toolbar.enabledAll()
hideBtn(id) 按钮id toolbar隐藏按钮[参数为按钮id]: toolbar.hideBtn(id)
showBtn(id) 按钮id toolbar显示按钮[参数为按钮id] toolbar.showBtn()