(5)ExtJS之工具栏toolbar 1

006_toolbar.js:

Ext.onReady(function(){
	var toolbar=new Ext.toolbar.Toolbar({//创建工具栏
		renderTo:Ext.getBody(),
		width:300
	
	});
	
	toolbar.add([//向工具栏中添加按钮
	{	
			text:'新建',//按钮上显示的文字
			handler:onButtonClick,//点击按钮的处理函数
			iconCls:'newIcon'//在按钮上显示的图标
	
	},
	{text:'打开',handler:onButtonClick,iconCls:'openIcon'},
	{text:'保存',handler:onButtonClick,iconCls:'saveIcon'}
	
	]);
	
	function onButtonClick(btn){//点击按钮时调用的处理函数
		alert(btn.text);//取得按钮上的文字
		
	}
	
});

 

 

JSP页面:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'JS1.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!-- extjs的样式文件 -->
	<link rel="stylesheet" type="text/css" href="js/extjs/resources/css/ext-all.css">
	<!-- extjs的核心文件 -->
	<script type="text/javascript" charset="utf-8" src="js/extjs/ext-all-debug.js"></script>
	<!-- 国际化文件 -->
	<script type="text/javascript" charset="utf-8" src="js/extjs/ext-lang-zh_CN.js"></script>
	
	<script type="text/javascript" charset="utf-8" src="base/006_toolbar.js"></script>
</head>
  
  <body><%--
   <input type="button" id="btn" value="点击" />
  --%></body>
</html>


 


 

你可能感兴趣的:((5)ExtJS之工具栏toolbar 1)